开发者

Log4net: separate log files for each class

开发者 https://www.devze.com 2022-12-23 02:27 出处:网络
i want to log messages from multiple classes. the p开发者_Python百科roblem is that currently i can log all messages into single file.i want to do this class A should log its messages into ALog.txt and

i want to log messages from multiple classes. the p开发者_Python百科roblem is that currently i can log all messages into single file.i want to do this class A should log its messages into ALog.txt and class B should log its messages into BLog.txt

please tell me the sample config file for these settings


In addition to the root logger, you can configure individual loggers with their own appenders. Assuming you are calling your loggers ClassA and ClassB you can do:

<root>
     <appender-ref ref="CommonAppender" />
</root>
<logger name="ClassA">
     <appender-ref ref="AppenderA" />
</logger>
<logger name="ClassB">
     <appender-ref ref="AppenderB" />
</logger>

This is further described here.

0

精彩评论

暂无评论...
验证码 换一张
取 消