Log4net.config

From MXMS Wiki
Revision as of 06:36, 31 March 2026 by Bjorn (talk | contribs)
Jump to navigationJump to search

To provide a robust logging framework MXMS uses log4net as it's logging framework. log4net can be configured using their xml configuration file which should be located in the workingdirectory and is named log4net.config. Appenders can be added to the log4.net logging engine.

Example configuration

<?xml version="1.0" encoding="UTF-8"?>
<log4net>
  <root>
    <priority value="ERROR"/>
    <appender-ref ref="rollingFile" />
  </root>
  <appender name="rollingFile" type="log4net.Appender.RollingFileAppender">
    <file type="log4net.Util.PatternString" value="mxms\Logs\trace-log.txt" />
    <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
    <appendToFile value="true" />
    <rollingStyle value="Date" />
    <maximumFileSize value="5MB" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value=" %date %-5level %logger - %message%newline" />
    </layout>
    <encoding value="utf-8" />
  </appender>
</log4net>