J
Joe Bloggs
Hi,
I am experiencing problem using log4Net within a WCF services. In my
service implementation, I would like to log messages using log4Net. I
host my service inside and IIS and hence my log4net config sits inside
the web.config file.
Here is a sample of my code:
-----------
[ServiceBehavior(Name = "Test", Namespace = "http://
EntDocGenWCFService.ServiceContracts/2008/03")]
public class Test : EntDocGenWCFService.ServiceContracts.ITest
{
// seems to throw an exception here
private static readonly ILog log =
LogManager.GetLogger(typeof(Test));
#region ITest Members
public Test()
{
XmlConfigurator.Configure();
}
public string Method1(string request)
{
log.Info(string.Format("Response to Request:{0} ",
request));
Trace.Write("Testing - using Trace appender");
return String.Format("Response to Request:{0} ", request);
}
#endregion
}
--------------------
Now it seems strange that instantiation a static instance of the
logger class is throwing me an exception. I desperately need help.
Why is that an issue instantiation a static log4Net logger in this
fashion? What is in WCF running instant that can throw an exception
like this? BTW, this happens in VS.Net environment. I haven't tried
running this outside on a server.
Thanks in advanced
I am experiencing problem using log4Net within a WCF services. In my
service implementation, I would like to log messages using log4Net. I
host my service inside and IIS and hence my log4net config sits inside
the web.config file.
Here is a sample of my code:
-----------
[ServiceBehavior(Name = "Test", Namespace = "http://
EntDocGenWCFService.ServiceContracts/2008/03")]
public class Test : EntDocGenWCFService.ServiceContracts.ITest
{
// seems to throw an exception here
private static readonly ILog log =
LogManager.GetLogger(typeof(Test));
#region ITest Members
public Test()
{
XmlConfigurator.Configure();
}
public string Method1(string request)
{
log.Info(string.Format("Response to Request:{0} ",
request));
Trace.Write("Testing - using Trace appender");
return String.Format("Response to Request:{0} ", request);
}
#endregion
}
--------------------
Now it seems strange that instantiation a static instance of the
logger class is throwing me an exception. I desperately need help.
Why is that an issue instantiation a static log4Net logger in this
fashion? What is in WCF running instant that can throw an exception
like this? BTW, this happens in VS.Net environment. I haven't tried
running this outside on a server.
Thanks in advanced