将来自另一个程序集的事件记录在单独的 log4net 日志中
我有以下 log4net 配置
<log4net debug="true">
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="Logs\\CurrentLog.txt"/>
<appendToFile value="true"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"/>
</layout>
</appender>
<root>
<priority value="ALL"/>
<appender-ref ref="RollingLogFileAppender"/>
</root>
</log4net>
是否可以将来自不同程序集的事件记录在不同的文件中?例如,消息来自
Castle.Facilities.NhibernateIntegration
如果不是这样,是否有更好的方法来过滤事件?
我不想将流限制为仅出现错误。
I have the following log4net configuration
<log4net debug="true">
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="Logs\\CurrentLog.txt"/>
<appendToFile value="true"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"/>
</layout>
</appender>
<root>
<priority value="ALL"/>
<appender-ref ref="RollingLogFileAppender"/>
</root>
</log4net>
Is it possible to log the events from a different assembly in a different file? For example, messages from
Castle.Facilities.NhibernateIntegration
If not that, is there a better way of filtering the events?
I do not want to limit the stream to only errors.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
记录器可以通过其名称进行配置。如果您遵循惯用 log4net 实践,您的记录器由其完整的
Namespace.TypeName
命名。您可以通过两种方式将附加程序分配给记录器。第一种是直接嵌入特殊的appender
或者定义appender并在logger中引用它
Loggers can be configured by their names. If you're following idiomatic log4net practices, your loggers are named by their full
Namespace.TypeName
. You can assign appenders to loggers in two ways.The first is to embed the special appender directly
Or to define the appender and reference it in the logger