Davids Interblag Gesammelte Werke.

22Nov/120

log4net: GetAllAppenders()

Returns a List of the IAppender Interface, which actually contracts:


string Name { get; set; }
void Close();
void DoAppend(LoggingEvent loggingEvent);

 
        public static List<log4net.Appender.IAppender> GetAllAppenders()
        {
            List<log4net.Appender.IAppender> appenders = new List<log4net.Appender.IAppender>();

            log4net.Repository.Hierarchy.Hierarchy h = (log4net.Repository.Hierarchy.Hierarchy)log4net.LogManager.GetRepository();
            appenders.AddRange(h.Root.Appenders.Cast<log4net.Appender.IAppender>());

            foreach (log4net.Repository.Hierarchy.Logger logger in h.GetCurrentLoggers())
            {
                appenders.AddRange(logger.Appenders.Cast<log4net.Appender.IAppender>());
            }

            return appenders;
        }

I recommend to check (or at least output) all appenders at the beginning of each project you use log4net!

Kommentare (0) Trackbacks (0)

Zu diesem Artikel wurden noch keine Kommentare geschrieben.


Leave a comment

*

Noch keine Trackbacks.