I have a framework library which would do a lot of things including logging. We are using log4net for logging. This framework has the static logging class LogManager, a static instance of ILog (logger) and static methods for logging INFO, WARNING, DEBUG etc.
The static instance logger is getting initialized like this:
public static class LogManager
{
private static ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
static ActivityLogManager()
{
}
public static void LogDebugy(string message, params object[] messageParameters)
{
// Log the message here
}
}
I have my own doubts if this is the right way to do it. I see from here that each class which needs to log, should declare a static instance of ILog.
Also I see that I would have to specify the Log4net config file in my framework project to log. Thought I read here that the config would get picked up from the executing assembly, but I don't see it happen.
Is there any way that I can have my logging done from my framework class with the configuration getting picked up from my web application (for my web app) or some other business library project (for my business class libraries)?
I would also like to add some custom info into my log (like custom business object ID etc, application pool, ServerName, ClientHostName, ClientBrowser, ClientOS, Client User etc). Is it possible?
I am using AdoNetAppender.
Edit1: Am using log4net.Config.XmlConfigurator(ConfigFile = @"log4net.config", Watch = true) in my assembly.cs to point to log4net config file.
Edit2: My ILog Logger is in my framework LogManager Class, so only one instance is generated for my application.