I have 3 different Application. I have log4net in a shared library which be shared among 3 application. Is it a bad practice to use the same logger for all the 3 services. I have written something like this
public class Log4netLogger
{
private ILog _logger = null;
public Log4netLogger(ILog logger)
{
_logger = logger;
}
public void write(Level logLevel, string message)
{
_logger.Logger.Log(_logger.GetType(),logLevel,message,null);
}
}
and in my Application 1 app_start i am injecting like this
myContainer.RegisterType<ILog>
(
new ContainerControlledLifetimeManager(),
new InjectionFactory(x => LogManager.GetLogger("Application 1"))
);
And in my code i am using like
_logger = myContainer.Resolve<log4net.ILog>();
Log4netLogger logMessage= new Log4netLogger(_logger);
logMessage.Write
(
log4net.Core.Level.Info,
logMessage
);
Also i one of the negatives that i think with this approach is i have install log4net in all of my 3 applications. So i am wondering whether i am doing something wrong or is there any better approach ?