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.

  1. Go to the SigningHub Installation Directory and open the respective SigningHub module folder, whose logs are required to be captured.

  2. Open the Logs folder.

  3. 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.

  1. 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.

  2. 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:

<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, or Debug).

  • 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.

  1. 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:

  1. Go to the SigningHub Installation Directory and open the respective SigningHub module folder.

  2. Open the Logs folder.

  3. Look for the NLog.txt file and edit it.

  4. 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.

  1. 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.

<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 the writeTo="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:

  1. Open Run > type regedit.

  2. Navigate to: Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application

  3. Add a new Key.

  4. 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:

  1. Go to the SigningHub Installation Directory and open the respective SigningHub module folder, whose logs are required to enable.

  2. Open the "Logs" folder.

  3. Look for the "NLog.txt" file and edit it.

  4. 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" />-->
  1. 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.

<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:

  1. Go to the SigningHub Installation Directory.

  2. Open the respective SigningHub module folder.

  3. Open the Logs folder and edit the NLog.txt file.

  4. Uncomment the Syslog target section.

<!--<target xsi:type="syslog" name="sysLog">
  <sl:layout xsi:type="SimpleLayout" text="{&quot;message&quot;: &quot;${message}&quot;}" />
  <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 the writeTo="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.

  1. 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.

  2. When using non-English logs, add encoding="UTF8" inside the EventLog target for proper text rendering

<target name="eventLog" xsi:type="AsyncWrapper">
  <target xsi:type="EventLog"
          name="eventLog1"
          layout="${LMlayout}"
          eventId="${event-properties:EventID}"
          source="SigningHubWeb"
          encoding="UTF8">
  </target>
</target>

Last updated

Was this helpful?