This example shows how to log to multiple appenders:
<log4net> <appender name="RollingFileAppenderUser" type="log4net.Appender.RollingFileAppender" > <param name="File" value="C:\TEMP\fcflnet_user.log" /> <param name="AppendToFile" value="true" /> <param name="RollingStyle" value="Size" /> <param name="MaxSizeRollBackups" value="100" /> <param name="MaximumFileSize" value="1024KB" /> <param name="StaticLogFileName" value="true" /> <layout type="log4net.Layout.PatternLayout"> <param name="ConversionPattern" value="%d [user: %X{user}] [fcsessionid: %X{session}] [%-5p] [%c]%n %m%n%n" /> </layout> <!-- Only show entries for a particular user --> <filter type="log4net.Filter.MDCFilter"> <param name="StringToMatch" value="user_name_goes_here"/> <param name="Key" value="user"/> </filter> <filter type="log4net.Filter.DenyAllFilter" /> </appender> <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender" > <param name="File" value="C:\TEMP\fcflnet.log" /> <param name="AppendToFile" value="true" /> <param name="RollingStyle" value="Size" /> <param name="MaxSizeRollBackups" value="100" /> <param name="MaximumFileSize" value="1024KB" /> <param name="StaticLogFileName" value="true" /> <layout type="log4net.Layout.PatternLayout"> <param name="ConversionPattern" value="%d [user: %X{user}] [fcsessionid: %X{session}] [%-5p] [%c]%n %m%n%n" /> </layout> </appender> <root> <level value="all" /> <appender-ref ref="RollingFileAppender" /> <appender-ref ref="RollingFileAppenderUser" /> </root> </log4net>
Please visit the Apache Logging Services: log4net Homepage for documentation on log4net. The most important links are the Manual, the FAQ, and the Configuration Examples