Reputation: 11360
I have a WCF service which is hosted on a windows service.
Where should I put XmlConfigurator.Configure();
?
In other applications, I can place it in Application_Start()
Can I place this in the OnStart() method of my windows service? Will I then able to instantiate the logger from my WCF service?
This is how I instantiate my logger:
private readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
This is what I have in my windows service
protected override void OnStart(string[] args)
{
if (AgentServiceHost != null)
{
AgentServiceHost.Close();
}
AgentServiceHost = new ServiceHost(typeof(CustoemrService));
AgentServiceHost.Open();
}
Upvotes: 0
Views: 1872
Reputation: 13990
Just put this piece of code in your AssemblyInfo.cs file:
[assembly: log4net.Config.XmlConfigurator(Watch=true)]
http://logging.apache.org/log4net/release/manual/configuration.html
Upvotes: 3