I am implementing Log4net in our application and for logging I am implementing AppenderSkeleton.
Since log4net resolves its appender using configuration setting I am not able to specify my custom service as a dependency injected using either constructor or property.
The reason I want to do so is because I want my appender to be unit tested using MOQ framework.
Following is a code sample of what I want to achieve.
public class LoggingAppender : AppenderSkeleton
{
private ICustomService service;
public LoggingAppender(ICustomService service)
{
this.service = service;
}
protected override void Append(log4net.Core.LoggingEvent loggingEvent)
{
service.Method("Data From loggingEvent");
}
}
I also found the following answer on stackoverflow. But it doesn't serve the purpose for me.
Is there any solution to this issue or should we follow any other approach in order to unit test it?