根据
the configuration page in the manual
:
log4net配置可以使用程序集级属性配置,而不是通过编程方式指定。
XML配置属性:
log4net.Config.XmlConfiguratorAttribute
允许
XmlConfigurator
要使用以下属性配置:
如果未指定config file或configfileextension属性,则应用程序配置文件(例如testapp.exe.config)将用作log4net配置文件。
示例用法:
// Configure log4net using the .config file
[assembly: log4net.Config.XmlConfigurator(Watch=true)]
// This will cause log4net to look for a configuration file
// called TestApp.exe.config in the application base
// directory (i.e. the directory containing TestApp.exe)
// The config file will be watched for changes.
我同意这有点模棱两可,但我将示例用法的存在解释为,如果没有上述属性,log4net将不会使用.config文件;事实上,它们指出您必须使用这两个属性中的一个,但不要说要完全删除该属性,这向我暗示了该属性(或程序调用)需要以您想要的方式使用app.config。