我怎样才能知道哪些log4net的附加目的地从使用的app.config [英] How can I tell log4net which appender to use from app.config
问题描述
我有一个快速log4net的问题。我怎么可以指定从app.config中使用的附加目的地?
这个特殊的配置文件引用了2个不同的追加程序。两者都是滚动文件追加程序,但它们指向不同的文件。在整个应用log4net的是被称为和类型传递到构造函数。像这样...
I had a quick log4net question. How can I specify which appender to use from the app.Config? This particular config file references 2 different appenders. Both are rolling file appenders but they point to different files. Throughout the application log4net is being called and a type is passed into the constructor. like this...
private static readonly ILog log = LogManager.GetLogger(typeof(Foo));
如何log4net的知道哪些附加目的地选择?你可以映射类型,以特定的命名的appender?我知道有5个构造函数GetLogger,你可以传递一个类型,一个appender的名字吗?我看repositoryName,不知道这是什么。如果任何人都可以在正确的方向指向我,我将不胜感激。我想一定类型集合专门登录一个附加目的地。
How does log4net know which appender to choose? Can you map types to specific named appenders? I know there are 5 constructors for GetLogger, can you pass a type and an appender name? I see "repositoryName", not sure what that is. If anyone can point me in the right direction I would greatly appreciate it. I would like a certain set of types to log specifically to one appender.
感谢您的任何提示,结果
〜CK在圣地亚哥
Thanks for any tips,
~ck in San Diego
推荐答案
使用<记录>
元素,使用完整的类名富
:
Use a <logger>
element, using the full class name of Foo
:
<logger name="full.parent.namespace.Foo">
<level value="WARN" />
<appender-ref ref="SomeAppender" />
</logger>
指定所需的输出附加器使用的最低水平和参考。
Specify a minimum level and reference to the required output appender to use.
您还可以使用一个<记录方式>
通过省略类名在一个特定的命名空间中的所有类
You can also use a single <logger>
for all classes in a particular namespace by omitting the class name.
<logger name="full.parent.namespace">
....
</logger>
这篇关于我怎样才能知道哪些log4net的附加目的地从使用的app.config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!