You need to add a separate appender for each level and add a
LevelMatchFilter to each for the desired level. e.g.:
<appender name="FileAppenderDebug" type="log4net.Appender.FileAppender">
<file value="log-debug.txt" />
<layout type="log4net.Layout.PatternLayout" value="%date %-5level
%logger - %message%newline" />
<filter type="log4net.Filter.LevelMatchFilter">
<levelToMatch value="DEBUG" />
</filter>
<filter type="log4net.Filter.DenyAllFilter" />
</appender>
(repeat for INFO, WARN, ERROR, and FATAL)
Then set the root logger up to try to log to all the appenders:
<root>
<level value="DEBUG" />
<appender-ref ref="FileAppenderDebug" />
<appender-ref ref="FileAppenderInfo" />
<appender-ref ref="FileAppenderWarn" />
<appender-ref ref="FileAppenderError" />
<appender-ref ref="FileAppenderFatal" />
</root>
In general I think that it will be rather difficult to follow the logs
across the different files. Personally I either just have one file, or I
have one file with all the logs and a separate file with Errors and
above. The Errors file gives a good starting point and full analysis can
be performed using the larger file. If you want to do that you can just
set the <threshold value="Error" /> property on an appender rather than
using filters.
Cheers,
Nicko
> -----Original Message-----
> From: Charles Johnson [mailto:[EMAIL PROTECTED]
> Sent: 24 June 2005 18:20
> To: log4net-user
> Subject: Log file for each level
>
> Doesn't sound like a brilliant idea to me, but my manager
> wants me to produce a separate log file for each log level
> and i was wondering what the best way to do this is?
>
> CJ
>