Log4Net in WCF service app

238 views
Skip to first unread message

rbr

unread,
Aug 27, 2010, 11:15:58 PM8/27/10
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Hello,

I have created a WCF service application that essentially is just an
interface to an underlying api. So, this WCF service just contains
the .svc file and web.config. The api it references has log4net
logging in it but requires the consumer to configure it and call the
XmlConfigurator.Configure() method to actually get logging running.
Without adding code into my service, is there a way to get this going?
The issue is that I want to keep my service as code-free as possible
and, from what I know, the only way to start the logging is with the
XmlConfigurator.Configure() method call. Am I missing something?

I'm sure I have left important details out so feel free to ask away.

TIA!

rbr

Benj Nunez

unread,
Sep 1, 2010, 9:41:07 AM9/1/10
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Hi,

As I understand it, you indicated that:

"The api it (your service) references has log4net logging in it but
requires the consumer to configure it and call the
XmlConfigurator.Configure() method to actually get logging running."


From what I've researched, I found a sample source on how the
XmlConfigurator.Configure() is used like so:

using Com.Foo;

// Import log4net classes.
using log4net;
using log4net.Config;

public class MyApp
{
private static readonly ILog log =
LogManager.GetLogger(typeof(MyApp));

static void Main(string[] args)
{
// BasicConfigurator replaced with XmlConfigurator.
XmlConfigurator.Configure(new
System.IO.FileInfo(args[0])); // <--- check this out

log.Info("Entering application.");
Bar bar = new Bar();
bar.DoIt();
log.Info("Exiting application.");
}
}


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


You may want to check the link I have provided above. It looks to me
like you simply
need to create a config file that will be read by your service (which
would in turn uses
an api underneath which has log4net logging access).




Regards,


Benj

Jamie Fraser

unread,
Sep 1, 2010, 2:39:46 PM9/1/10
to dotnetde...@googlegroups.com
I don't think that is what he is asking I'm afraid.

RBR - could you possibly use something like Postsharp (or some other
AOP framework) to intercept your method calls and call
XmlConfigurator.Configure if necessary?

Reply all
Reply to author
Forward
0 new messages