Question

I have a separate Log4Net.config file with 2 appenders and 2 loggers, 1 logger for each appender. There is no <Root /> logger.

I am trying to add code to my application that will retrieve the filename for the logger to allow the user to view the log files for each of the appenders from an application menu selection. I have tried the below code but it returns no appenders. What did I miss?

I should also have mentioned that I am using the slf4net.log4net facade

log4net.Repository.ILoggerRepository repo = LogManager.GetRepository();

foreach (log4net.Appender.IAppender appender in repo.GetAppenders())
{
    string x = appender.Name;
}
Was it helpful?

Solution

I found the answer in this post log4Net config in external file does not work. After adding the ConfigFile name to the assemblyinfo entry it began working

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top