Skip to content
Luca Petrini edited this page Feb 27, 2016 · 6 revisions

#Configuring Log4Net

Log4Net must be setup to write XML content in XmlLayoutSchemaLog4j layout to log files. This configuration normally should be performed just once and it is quite simple. Just a few lines need to be added to your application config file (or log4net config file) to configure it to use this format. We suggest you to create separate appender named FileXmlAppender to create log files in XmlLayoutSchemaLog4j layout. Your log4net section should look like this:

<log4net>
    <appender name="FileAppenderXml" type="log4net.Appender.FileAppender">
        <file type="log4net.Util.PatternString" value="sample-log.xml"/>
        <appendToFile value="true"/>        
        <layout type="log4net.Layout.XmlLayoutSchemaLog4j">
            <locationInfo value="true"/>
        </layout>
        <param name="Encoding" value="utf-8" /> 
    </appender>
    <!-- other appenders defined here -->

    <root>
        <level value="ALL" />
        <appender-ref ref="FileAppenderXml" />
        <!-- other appenders enabled here -->
    </root>
</log4net>
Clone this wiki locally