Reputation: 49
I have a console app and I am trying to implement log4Net for it.
I did the following steps -
Created Log4Net.config -
Created the LogHelper.cs class -
Added the following to the AssemblyInfo.cs [assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4net.config", Watch = true)]
But the logging doesnt seem to work? Can someone suggest what needs to be done for the logging to work in th console app?
Upvotes: 1
Views: 5567
Reputation: 73243
Make sure the config file is set to copy to the output directory.
In the log4net documentation for assembly attributes it says:
".. if you use configuration attributes you must invoke log4net to allow it to read the attributes. A simple call to LogManager.GetLogger will cause the attributes on the calling assembly to be read and processed. Therefore it is imperative to make a logging call as early as possible during the application start-up, and certainly before any external assemblies have been loaded and invoked."
Upvotes: 5