Tim
Tim

Reputation: 1249

Log4Net Retrieve Appenders Programmatically

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;
}

Upvotes: 1

Views: 684

Answers (1)

Tim
Tim

Reputation: 1249

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

Upvotes: 1

Related Questions