Logging configuration
Logging targets in SigningHub
In addition to the default logging inside a NLog file, SigningHub now supports logging on multiple targets, i.e. File (default), Console, JSON Format, Event Viewer, and Syslog.
Each target further has three levels of logging (Info, System, and Debug), where:
Infoprovides a basic level of logging.Systemprovides system-level logging.Debugprovides detailed logging information.
You may choose these logging levels as per your requirement. Let's discuss the configurations to enable logging on each target:
Enable logging in file (Default)
By default, file-based logging is already enabled in SigningHub. All application logs are written into a text file under the logs folder.
Go to the SigningHub Installation Directory and open the respective SigningHub module folder, whose logs are required to be captured.
Open the Logs folder.
You will find a default file log entry, for example:
<target name="default" xsi:type="AsyncWrapper">
<target xsi:type="File" name="default1" fileName="logs/${App}Log.txt" layout="${DLMlayout}" keepFileOpen="false"
archiveFileName="logs/archive/${App}Log_${shortdate}.{#}.log"
archiveAboveSize="50000520" archiveNumbering="Sequence" archiveEvery="Day"
maxArchiveFiles="30" />
</target>Logs are automatically archived daily or when the log file size exceeds 500 MB, with a maximum of 30 archives retained.
The
${App}variable is set to"api"in the default configuration. You can change this if logging needs to be maintained separately for different modules.Layouts are controlled through variables such as
${DLMlayout},${LMlayout}, and${Mlayout}, which formats log output consistently across targets.
Changing file logging levels
Edit the NLog.txt file from the same location.
Search the rule entries, such as:
Change the
minLevelvalue as required (Info,System, orDebug).Save the changes and close the NLog.txt file.
Enable logging in console
Console logging is also supported in SigningHub. This is particularly useful during development, debugging, or when running SigningHub in environments where console output is monitored.
By default, console logging is enabled with the following configuration:
Changing console logging levels
Console logging rules are set separately for SigningHub, Microsoft, and System components:
Open the NLog.txt file.
Adjust the
minLevelvalues in the above rules.Save and restart SigningHub.
Console logging supports UTF-8 encoding, ensuring non-English characters are displayed correctly in the output window.
Enable logging in the JSON format
By default, JSON logging is disabled in SigningHub. You can turn it on and off as required. To enable this:
Go to the SigningHub Installation Directory and open the respective SigningHub module folder.
Open the Logs folder.
Look for the NLog.txt file and edit it.
Uncomment the JSON logging target and rule as shown below.
Then enable the corresponding rules:
For more details regarding JSON layout, see NLog JsonLayout.
Each SigningHub module has its own NLog file. You need to enable JSON logging separately for each if required.
Changing JSON logging levels
After enabling the JSON target, adjust the logging levels under the <rules> section. Uncomment (or add) the rules and set minlevel as required.
Open the NLog.txt file for the relevant module.
In
<rules>, locate thewriteTo="jsonLog"entries shown above.Change
minlevelto your desired verbosity (e.g.,Debug,Info,System,Error,Fatal).Save the file (and restart the app/service if applicable).
Enable Logging for Event Viewer
Logging inside Windows Event Viewer is also supported but disabled by default.
There are two steps to enable this:
Create a source in Event Viewer.
Update the NLog.txt file.
Creating a source in Event Viewer
The source is created inside the System Registry. It is mandatory, and you need to manually create it as IIS does not have the rights to create it. For this:
Open Run > type
regedit.Navigate to:
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\ApplicationAdd a new Key.
The name should match the
sourceattribute defined in NLog (e.g.SigningHubAPI)
For more details regarding source creation, see NLog issue #1537.
Updating the NLog.txt file
For this:
Go to the SigningHub Installation Directory and open the respective SigningHub module folder, whose logs are required to enable.
Open the "Logs" folder.
Look for the "NLog.txt" file and edit it.
Uncomment the EventLog target section:
Then enable the corresponding rules:
When using non-English logs, add
encoding="UTF8"inside the EventLog target for proper text rendering.
Changing logging levels
To change the logging level:
Edit the NLog.txt file from the same location.
Search the text
<logger name="*" writeTo="logfile" minlevel="Info">in the file content.Change the minlevel value shown inside quotes as required, i.e.
"Trace","Debug","Info","System","Error", or"Fatal".Save the changes and close the NLog.txt file.
Enable logging for Syslog
You can also push the logs to the Syslog Server. For this, the Syslog Server should be installed. By default, it is disabled in SigningHub, but you can turn it on and off as required.
To enable pushing logs on Syslog:
Go to the SigningHub Installation Directory.
Open the respective SigningHub module folder.
Open the Logs folder and edit the NLog.txt file.
Uncomment the Syslog target section.
Enable the corresponding rules:
For more details, see NLog Syslog target.
Changing the logging levels
After enabling the Syslog target, adjust the logging levels under the <rules> section. Uncomment (or add) the rules and set minlevel as required.
Open the NLog.txt file for the relevant module.
In
<rules>, locate thewriteTo="syslog"entries shown above.Change minlevel to your desired verbosity (e.g., Debug, Info, System, Error, Fatal).
Save the file (and restart the app/service if applicable).
Troubleshooting
Sometimes the application may not write logs even when configured. Common causes include insufficient write permissions (e.g., IIS processes not having access to the log directory).
NLog swallows runtime exceptions by default. The following settings can help in diagnosing issues:
<nlog throwExceptions="true" />– forces NLog to surface exceptions instead of swallowing them. Useful during deployment troubleshooting.<nlog throwConfigExceptions="true" />– specifically enables configuration exceptions to bubble up. Recommended for production environments.<nlog internalLogLevel="Trace|Debug|Info|Warn|Error|Fatal" />– controls internal NLog verbosity. Can be redirected to File or Console for diagnostics.
In the provided configuration,
throwExceptions="true"is enabled. It is strongly recommended to set this back to"false"in production to prevent logging errors from affecting application stability.When using non-English logs, add
encoding="UTF8"inside the EventLog target for proper text rendering
Last updated
Was this helpful?

