开发者

log4net XMLConfigurato.Configure doesn't exist

开发者 https://www.devze.com 2023-02-22 23:54 出处:网络
I\'m trying to set up log4net logging on my project. 开发者_开发问答I think everything is setup correctly, I have the reference to the dll and I\'ve got a config file for it.

I'm trying to set up log4net logging on my project. 开发者_开发问答I think everything is setup correctly, I have the reference to the dll and I've got a config file for it.

For some reason when I try to cofigure it using log4net.Config.XMLConfigurator.Configure() it only recognises the call up to log4net.Config.XMLConfigurator. The intellisense cannot see the Configure method in the XMLConfigurator class and when I compile, it throws an error:

Error 40 Invalid token '(' in class, struct, or interface member declaration

What could be wrong?


We use Log4Net extensively, and have found that the easiest way of doing it is to name the config file the same as the application executable, e.g. Myapp.exe.log4net.

You can then put a line in your AssemblyInfo.cs file to pick up this file

[assembly: log4net.Config.XmlConfigurator(ConfigFileExtension="log4net",Watch=true)]

See http://logging.apache.org/log4net/release/manual/configuration.html

Don't forget to set your .log4net file to Copy to output directory!

0

精彩评论

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