Log4net:每个类的单独日志文件 [英] Log4net: separate log files for each class

查看:353
本文介绍了Log4net:每个类的单独日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想记录来自多个类别的消息.问题是当前我可以将所有消息记录到单个文件中.我想要执行此操作,A类应将其消息记录到ALog.txt中,而B类应将其消息记录到BLog.txt中

i want to log messages from multiple classes. the problem 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

推荐答案

除了root记录器之外,您还可以使用自己的附加程序配置各个记录器.假设您正在呼叫记录器ClassAClassB,则可以执行以下操作:

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.

这篇关于Log4net:每个类的单独日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆