I need to create a simple system to abstract logging platforms. The idea is that I'd like to be able to exchange or activate a logging platform (nlog
, log4net
, enterprise library
) via some configuration (this shouldn't be a problem). I know that I would need a wrapper for each platform that I want to support that would load the necessary dll's and create the loggers.
I was thinking of creating an abstract class or an interface providing the most common methods like Log
, Debug
, Trace
, etc.:
interface ILogger
{
void Log(...);
void Debug(...);
// etc.
}
class NLogPlatform : ILogger
{
// create nlog, load config etc.
}
class Log4NetPlatform : ILogger
{
// create log4net, load config etc.
}
class LoggerFactory
{
public static CreateLogger(...)
{
// read settings and create a logger.
}
}
At first I thought of a log-provider but then I found that provider is not a pattern at all so I looked at .NET Design Patterns but nothing really seems to be suitable here. Did I miss something or is there just no pattern for it?
I haven't really started yet because this time I'd rather go in the right direction from the beginning then refactor several tools later.
Could you tell me what I should take into consideration when designing such a system and whether there is a pattern for this?
.dll
for another between runs of the program.