Logging

Viper.NET uses Apache log4net as log platform. log4net is parameterized via a configuration file. This file can be modified at runtime, changes take effect immediately after saving the file.

In log4net a distinction is made between Logger and Appender. Viper.NET sends the log messages to a logger, which forwards the messages to the appenders configured for it.

By default, Viper.NET uses RollingFileAppender and the custom GBufferAppender to display log messages in the user interface.

RollingFileAppender

The RollingFileAppender writes a log file. When certain criteria (size or time) are reached, the previous log file is archived and a new log file is created.

<appender name="FileAppender" type="log4net.Appender.RollingFileAppender">
    <param name="File" value="D:/log/Viper_6.4.2.log" />
    <param name="AppendToFile" value="true" />
    <param name="MaxSizeRollBackups" value="10" />
    <!--param name="RollingStyle" value="Date" /-->
    <param name="RollingStyle" value="Size" />
    <param name="MaximumFileSize" value="10MB" />
    <param name="StaticLogFileName" value="true" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%d [%t] %-5p - %m%n" />
    </layout>
  </appender>

In particular, the File parameter may need to be adjusted.

All parameters are described in the official documentation of Apache log4net.

GBufferAppender

The GBufferAppender keeps the latest log messages in memory, making them easy to display in the user interface. The Log-tab in Viper.NET displays all configured GBufferAppenders.

For the analysis of rare errors, a GBufferAppender can also be configured to automatically save a dump of the log buffer when certain log messages occur.

<appender name="GAppenderRoot" type="Gefasoft.MAK.Logging.GBufferAppender">
  <param name="BufferSize" value="10000000"/>
  <param name="DumpFile" value="D:/log/Viper_6.4.2_Dump.log" />
  <param name="MaxSizeRollBackups" value="3" />
  <param name="MaxCharsToDisplay" value="100000"/>
  <param name="DisplayName" value="Main"/>
  <param name="SortId" value="1" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%d [%t] %-5p - %m%n" />
  </layout>

  <AutoDumpSettings type="Gefasoft.MAK.Logging.GAppenderAutoDumpSettings">
    <param name="DumpFile" value="D:/log/Viper_6.4.2_AutoDump.log" />
    <param name="MaxSizeRollBackups" value="10" />
    <param name="DumpSize" value="1000000"/>
    <param name="TriggerPattern" value="regex:"/>
    <param name="LogLevel" value="OFF"/>
    <param name="AdditionalAppenderToAutodump" value ="" />
    >
  </AutoDumpSettings>
</appender>
  • BufferSize: Size of the buffer for log messages in bytes.

  • DumpFile: A “dump” of the current log buffer can be written to this file via the interface.

  • MaxSizeRollbacks: Maximum number of dump files.

  • MaxCharsToDisplay: Maximum number of characters to be displayed in the viewer.

  • DisplayName: Display name of the logger

  • SortId: Manual sort order for the GUI.

  • layout: Formatting of the log message.

  • AutoDumpSettings - DumpFile: File for the AutoDump - MaxSizeRollbacks: Maximum number of AutoDump files. - DumpSize: Number of characters for the AutoDump. - TriggerPattern: Search pattern for the log message for which the AutoDump is to be triggered. A regular expression can optionally be specified after the regex: prefix. - LogLevel: TriggerPattern is only checked for log messages starting at this log level. - AdditionalAppenderToAutodump: Additional GBufferAppender for which the AutoDump should also be executed.