Menu

log4net

7.12.2016 - C#

Přidání console appenderu v kódu

using log4net.Appender;
using log4net.Config;
using log4net.Core;
using log4net.Layout;
using log4net.Util;

        public static void AddConsoleAppender()
        {
            //var layout = new PatternLayout(@"%date [%thread] %-5level %c - %m%n");
            var layout = new PatternLayout(@"%-5level - %m%n");
            layout.ActivateOptions();
            var _log4netAppender = new ConsoleAppender
            {
                Layout = layout,
                Name = "ConsoleAppender"
            };
            _log4netAppender.ActivateOptions();
            BasicConfigurator.Configure(_log4netAppender);
        }