- Console
- Text file
- Event log
rootand then e.g.:
!--level value="ALL" /
appender-ref ref="ConsoleLog" /
appender-ref ref="Log" /
appender-ref ref="EventLog" /--
/root
appender name="ConsoleLog" type="log4net.Appender.ColoredConsoleAppender"and called via e.g. :
mapping
level value="ERROR" /
foreColor value="White" /
backColor value="Red, HighIntensity" /
/mapping
layout type="log4net.Layout.PatternLayout"
conversionPattern value="%date [%thread] %level %logger - %message%newline"/
/layout
/appender
private static readonly ILog LogConsole = log4net.LogManager.GetLogger("ConsoleLog");
But when I tried e.g.
LogConsole.Info
all three logs were invoked and all three entries were written!
Turns out you need to remove the root level and use e.g.:
logger name="ConsoleLog"where the "appender-ref" points to the correct log.
level value="ALL" /
appender-ref ref="ConsoleLog" /
/logger
Then all works as expected.
Note: angle brackets removed for display purposes!
Enjoy!
No comments:
Post a Comment