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:
Info
provides a basic level of logging.System
provides system-level logging.Debug
provides 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.
Changing file logging levels
Edit the NLog.txt file from the same location.
Search the rule entries, such as:
<logger name="SigningHub*" minlevel="Info" writeTo="default" />
<logger name="Microsoft.*" minlevel="Warn" writeTo="default" />
<logger name="System.*" minlevel="Warn" writeTo="default" />
Change the
minLevel
value 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:
<target name="console" xsi:type="Console"
layout="${time} [${level:uppercase=true}] ${logger:shortName=true}: ${message} ${exception:format=tostring}"
encoding="utf-8" />
Changing console logging levels
Console logging rules are set separately for SigningHub, Microsoft, and System components:
<logger name="SigningHub*" minlevel="Debug" writeTo="console" />
<logger name="Microsoft.*" minlevel="Warn" writeTo="console" />
<logger name="System.*" minlevel="Warn" writeTo="console" />
Open the NLog.txt file.
Adjust the
minLevel
values in the above rules.Save and restart SigningHub.
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.
<!--<target name="jsonLog" xsi:type="AsyncWrapper">
<target xsi:type="File" name="jsonLog1" fileName="logs/${App}Log.json" keepFileOpen="false"
archiveFileName="logs/archive/${App}Log_${shortdate}.{#}.log"
archiveAboveSize="50000520" archiveNumbering="Sequence" archiveEvery="Day"
maxArchiveFiles="30">
<layout xsi:type="JsonLayout" excludeProperties="Comma-separated list (string)">
<attribute name="time" layout="${longdate}" />
<attribute name="level" layout="${level:upperCase=true}" />
<attribute name="message" layout="${Mlayout}" />
</layout>
</target>
</target>-->
Then enable the corresponding rules:
<!--<logger name="SigningHub*" minlevel="Info" writeTo="jsonLog" />-->
For more details regarding JSON layout, see NLog JsonLayout.
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.
<logger name="SigningHub*" minlevel="Info" writeTo="jsonLog" />
<logger name="Microsoft.*" minlevel="Warn" writeTo="jsonLog" />
<logger name="System.*" minlevel="Warn" writeTo="jsonLog" />
Open the NLog.txt file for the relevant module.
In
<rules>
, locate thewriteTo="jsonLog"
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).
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\Application
Add a new Key.
The name should match the
source
attribute 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:
<!--<target name="eventLog" xsi:type="AsyncWrapper">
<target xsi:type="EventLog" name="eventLog1" layout="${LMlayout}"
eventId="${event-properties:EventID}" source="SigningHubAPI"></target>
</target>-->
Then enable the corresponding rules:
<!--<logger name="SigningHub*" minlevel="Info" writeTo="eventLog" />-->
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.
<logger name="*" writeTo="logfile" minlevel="Debug" />
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.
<!--<target xsi:type="syslog" name="sysLog">
<sl:layout xsi:type="SimpleLayout" text="{"message": "${message}"}" />
<sl:messageCreation>
<sl:facility>Local4</sl:facility>
<sl:rfc>Rfc5424</sl:rfc>
<sl:rfc5424>
<sl:hostname xsi:type="SimpleLayout" text="${machinename}" />
<sl:appName xsi:type="SimpleLayout" text="" />
<sl:disableBom>true</sl:disableBom>
</sl:rfc5424>
</sl:messageCreation>
<sl:messageSend>
<sl:protocol>tcp</sl:protocol>
<sl:tcp>
<sl:server>127.0.0.1</sl:server>
<sl:port>1468</sl:port>
</sl:tcp>
</sl:messageSend>
</target>-->
Enable the corresponding rules:
<!--<logger name="SigningHub*" minlevel="Info" writeTo="sysLog" />-->
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.
<logger name="SigningHub*" minlevel="Info" writeTo="syslog" />
<logger name="Microsoft.*" minlevel="Warn" writeTo="syslog" />
<logger name="System.*" minlevel="Warn" writeTo="syslog" />
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.
Last updated
Was this helpful?