setting up XmlConfigurator Common Logging with log4net

950 views Asked by At

I have been looking at creating a common logging library for the company I work for, based on a blog by Daniel Cazzulino. so we can switch one out for another without to much disruption.

The first library I looked to use is log4net, but I cannot work out how or where you would setup a call to the XmlConfigurator.

I have tried adding an assembly on the project being logged, which kind of defeats the object of the exercise I feel, but that doesn't appear to work any way.

I have tried adding it as an assembly of the log4net Logging library, but that doesn't appear to work.

I have also tried calling log4net.Config.XmlConfigurator.Configure(); from the TraceManager.Get method, but all the log options (IsDebugEnabled, IsWarnEnabled, ...) are disabled.

public partial class TracerManager : ITracerManager
{
    /// <summary>
    /// Gets a tracer instance with the specified name.
    /// </summary>
    public ITracer Get(string name)
    {
        log4net.Config.XmlConfigurator.Configure();
        var logger = LogManager.GetLogger(name);
        return new Log4NetAdapter(logger);
    }
    /// The rest
}

Do I need to do something else? Does the app config need to be in in the logging library?

[Edit 1]

Feel very silly....

I'd added [assembly: XmlConfigurator(Watch = true)] to my Logging.Log4Net library, but I wasnt instantiating the TracerManager in my application on the tests I was performing... ID-10Tango issue

1

There are 1 answers

0
Luke Duddridge On BEST ANSWER

I'd added [assembly: XmlConfigurator(Watch = true)] to my Logging.Log4Net library, but I wasnt instantiating the TracerManager in my application on the tests I was performing...

ID-10Tango issue