log4net: log information into different log files
- by Daoming Yang
I have the following configurations in my web.config file, but how can I log the information into data.txt and general.txt separately in C#?
Could anyone provide some sample code for me?
<appender name="GeneralLog" type="log4net.Appender.RollingFileAppender">
<file value="App_Data/Logs/general.txt" />
<appendToFile value="true" />
<maximumFileSize value="2MB" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="5" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d{HH:mm:ss.fff} [%t] %-5p %c - %m%n" />
</layout>
</appender>
<appender name="DataLog" type="log4net.Appender.RollingFileAppender">
<file value="App_Data/Logs/data.txt" />
<appendToFile value="true" />
<maximumFileSize value="2MB" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="5" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d{HH:mm:ss.fff} [%t] %-5p %c - %m%n" />
</layout>
</appender>