1
I use Log4net in my application. I need to create a configuration that "deposit" everything from level="INFO" in a file and everything that is light="ERROR" in another file.
But even following the tutorials, do not work. Look how I did below. Thanks in advance...
<log4net>
<root name="LogFilesAll">
<level value="ERROR" />
<appender-ref ref="RollingFileErro"/>
<level value="INFO" />
<appender-ref ref="RollingFileInfo"/>
<level value="DEBUG" />
<appender-ref ref="Console"/>
</root>
<!-- APPENDER DE ERRO -->
<appender name="RollingFileErro" type="log4net.Appender.RollingFileAppender">
<file value="GestorReq32Error.log" />
<appendToFile value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5p %date{dd/MM/yyyy HH:mm:ss} %message%newline" />
</layout>
<lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
<appendToFile value="true"/>
<maximumFileSize value="15MB"/>
<staticLogFileName value="true"/>
<rollingStyle value="Size"/>
<maxSizeRollBackups value="10"/>
</appender>
<!-- APPENDER DE ERRO -->
<appender name="RollingFileInfo" type="log4net.Appender.RollingFileAppender">
<file value="GestorReq32Info.log" />
<appendToFile value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5p %date{dd/MM/yyyy HH:mm:ss} %message%newline" />
</layout>
<lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
<appendToFile value="true"/>
<maximumFileSize value="15MB"/>
<staticLogFileName value="true"/>
<rollingStyle value="Size"/>
<maxSizeRollBackups value="10"/>
</appender>
<appender name="Console" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%5level [%thread] (%file:%line) - %message%newline" />
</layout>
</appender>
</log4net>
The archive
log4net.config
is along the.exe
of its application?– Marco Giovanni
Yes, it is in the same directory and I can generate the log, but only one file.
– SantanaFire