Synergy Logging - NLog - Version 4.3.34 and later

This article is only relevant for Synergy 4.6.34 and later, as these versions of the application use NLog for logging.
 
For Synergy 4.6.33 and earlier, Log4Net is used instead. For documentation, please refer to the relevant article.
 
NOTE: When upgrading Synergy from version 4.6.33 or earlier to version 4.6.34 or later, a new default logging.config will be created. Any customisations made to the existing logging.config will therefore be lost and need to be reworked to function in NLog
 
 
Synergy allows the logging of a variety of information from the main application itself, and installed components and services. This article will cover how to configure this logging.
 

Synergy Logging

Synergy can store logs on the server at a chosen level of detail. Logging is enabled automatically, and no further actions are required to have the default level (Error+) of logging running.
 
All logs are stored by default in:
    %Synergy Root%\data\logs\
 
The most recent logs from the core application are stored in:
    %Synergy Root%\data\logs\web.log
 
Any Services running in Synergy can also create logs. In this case, they will be stored in a separate log that is named for the Service.
 
With the default settings, the log will automatically be broken into 1MB files (the number in the config file will be 1048576 bytes which is equivalent to 1MB), with up to 10 of these backup logs stored. When a log beyond the 10th is created, the oldest backup log is removed.
 
 

Logging Configuration

Synergy uses the open source NLog library to handle its logging. Examples of alternative logging options (file per day, to SQL database, etc.) can be found on NLog's private website.
 
Whenever editing logging settings, it is recommended that a backup is taken of the file before editing it. This ensures that if something goes wrong the logging state can be reverted to normal simply by restoring the backup, and is a safer way to make temporary changes (for example to the logging level) than manually making and reverting changes within the file.
 
The Synergy Website, Application Pool, and services must be restarted after any changes to logging are made for them to take effect. This will cause a short downtime in the application and so is advisable to do outside of usage hours.

Logging Levels

The most common change likely to be made to logging is to alter the logging level. The level sets the minimum severity of an event required for it to be logged, running from entirely disabled to logging all events.
 
To change the logging level in one of the open configuration files, search within the file to find a line like this:
    <logger name="*" minlevel="Error" writeTo="logfile" />
 
The minlevel section of this string declares the minimum severity of an event for it to be logged, selected from the following potential levels (in order of comprehensiveness):
 
  1. Trace - very detailed logs, which may include high-volume information such as protocol payloads. This log level is typically only enabled during development
  2. Debug - debugging information, less detailed than trace, typically not enabled in production environment.
  3. Info - information messages, which are normally enabled in production environment
  4. Warn - warning messages, typically for non-critical issues, which can be recovered or which are temporary failures
  5. Error - error messages - most of the time these are Exceptions
  6. Fatal - very serious errors!
 
Typically, the level will be set to ERROR by default, meaning that it will only report errors and fatal conditions.
 
For most purposes, when asked to enable logging (unless specified otherwise) this means to set the level to Trace, thus harvesting all possible information to aid in troubleshooting efforts. However, do be aware that this will generate a significant load on the application, and it’s encouraged that you only set the level to Trace for brief durations while actively testing a problem!
 
Ideally, the program is setup and ready to run through the problem that prompted the need for troubleshooting, the logging level is set to Trace for that program briefly while the problem is reproduced, and then the logging level is returned to the previous setting upon completion.

Log File Retention

By default, Synergy logging is set to maintain the most recent 10 log files of 1 MB each. However, on production systems, this may only span a few minutes if the Logging Level has been set to Debug or Trace. For these cases it is advised to increase the retained total logs up to 100 MB or more to provide a greater time span of logs.
 
Each log file should not be set to go above 10MB (10485760 bytes).
 
Changing Log Retention is achieved by changing the 2 settings from their default values:
maxArchiveFiles="9"
archiveAboveSize="1048576"
For 100MB total logs:
maxArchiveFiles="9"
archiveAboveSize="10485760"
Or for greater , ie 500MB of log retention:
maxArchiveFiles="49"
archiveAboveSize="10485760"