Example #1
0
        /// <inheritdoc />
        public void Write(string message, LogLevel logLevel)
        {
            switch (logLevel)
            {
            case LogLevel.Debug:
                _inner.Debug(message);

                break;

            case LogLevel.Info:
                _inner.Info(message);

                break;

            case LogLevel.Warn:
                _inner.Warn(message);

                break;

            case LogLevel.Error:
                _inner.Error(message);

                break;

            case LogLevel.Fatal:
                _inner.Fatal(message);

                break;

            default:
                _inner.Debug(message);

                break;
            }
        }
 public void Warn(Func <string> message)
 {
     if (_logger.IsWarnEnabled)
     {
         _logger.Warn(DecorateMessageWithAuditInformation(message.Invoke()));
     }
 }
Example #3
0
        public static void DefaultCategoryTest()
        {
            global::log4net.Tests.Appender.CategoryTraceListener categoryTraceListener =
                new global::log4net.Tests.Appender.CategoryTraceListener();

            // Trace not in Xamarin.iOS????????????????????????
            // http://forums.xamarin.com/discussion/comment/20763
            // TODO: raise issue on forum!!!
            //
            // System.Diagnostics.Trace.Listeners.Clear();
            // System.Diagnostics.Trace.Listeners.Add(categoryTraceListener);

            global::log4net.Repository.ILoggerRepository rep =
                global::log4net.LogManager.CreateRepository(Guid.NewGuid().ToString());

            global::log4net.Appender.TraceAppender traceAppender =
                new global::log4net.Appender.TraceAppender();

            traceAppender.Layout = new global::log4net.Layout.SimpleLayout();
            traceAppender.ActivateOptions();

            global::log4net.Config.BasicConfigurator.Configure(rep, traceAppender);

            global::log4net.ILog log = global::log4net.LogManager.GetLogger(rep.Name, new LogSamples().GetType());

            log.Debug("Debug message HolisticWare DefaultCategoryTest()");
            log.Info("Info message HolisticWare DefaultCategoryTest()");
            log.Warn("Warning message HolisticWare DefaultCategoryTest()");
            log.Error("Error message HolisticWare DefaultCategoryTest()");
            log.Fatal("Fatal message HolisticWare DefaultCategoryTest()");

            return;
        }
Example #4
0
        public static void AddingMultipleAppenders()
        {
            global::log4net.Tests.Appender.CountingAppender counting =
                new global::log4net.Tests.Appender.CountingAppender();
            global::log4net.Appender.ConsoleAppender console =
                new global::log4net.Appender.ConsoleAppender();


            global::log4net.Repository.Hierarchy.Hierarchy hierarchy =
                (global::log4net.Repository.Hierarchy.Hierarchy)
                global::log4net.LogManager.GetRepository();
            hierarchy.Root.AddAppender(counting);
            hierarchy.Root.AddAppender(console);
            hierarchy.Configured = true;

            global::log4net.ILog log = global::log4net.LogManager.GetLogger(new LogSamples().GetType());

            log.Debug("Debug message HolisticWare AddingMultipleAppenders()");
            log.Info("Info message HolisticWare AddingMultipleAppenders()");
            log.Warn("Warning message HolisticWare AddingMultipleAppenders()");
            log.Error("Error message HolisticWare AddingMultipleAppenders()");
            log.Fatal("Fatal message HolisticWare AddingMultipleAppenders()");

            return;
        }
Example #5
0
        public static void LogInStringAppender()
        {
            LogForStringAppender.Debug("Debug message HolisticWare LogInStringAppender()");
            LogForStringAppender.Info("Info message HolisticWare LogInStringAppender()");
            LogForStringAppender.Warn("Warning message HolisticWare LogInStringAppender()");
            LogForStringAppender.Error("Error message HolisticWare LogInStringAppender()");
            LogForStringAppender.Fatal("Fatal message HolisticWare LogInStringAppender()");

            return;
        }
Example #6
0
        public static void LogToFiles()
        {
            LogForFiles.Debug("Debug message LogToFiles()" + System.Environment.NewLine + @"  " + Message);
            LogForFiles.Info("Info message LogToFiles()" + System.Environment.NewLine + @"  " + Message);
            LogForFiles.Warn("Warning message LogToFiles()" + System.Environment.NewLine + @"  " + Message);
            LogForFiles.Error("Error message LogToFiles()" + System.Environment.NewLine + @"  " + Message);
            LogForFiles.Fatal("Fatal message LogToFiles()" + System.Environment.NewLine + @"  " + Message);

            return;
        }
Example #7
0
        public static void Log04()
        {
            global::log4net.Appender.ConsoleAppender appender_console = null;
            global::log4net.Appender.DebugAppender   appender_debug   = null;
            global::log4net.Appender.TraceAppender   appender_trace   = null;
            //global::log4net.Appender.AndroidLogAppender appender_android = null;

            appender_console = new global::log4net.Appender.ConsoleAppender();
            appender_debug   = new global::log4net.Appender.DebugAppender();
            //appender_trace		= new global::log4net.Appender.TraceAppender();
            //appender_android	= new global::log4net.Appender.AndroidLogAppender();

            global::log4net.Appender.AppenderSkeleton[] appenders = null;
            appenders = new global::log4net.Appender.AppenderSkeleton[]
            {
                appender_console
                , appender_debug
                //, appender_trace
                //, appender_android
            };

            global::log4net.Repository.Hierarchy.Hierarchy hierarchy = null;
            hierarchy =
                (global::log4net.Repository.Hierarchy.Hierarchy)
                global::log4net.LogManager.GetRepository();

            hierarchy.Root.AddAppender(appender_console);
            hierarchy.Root.AddAppender(appender_debug);
            //hierarchy.Root.AddAppender(appender_trace);
            //hierarchy.Root.AddAppender(appender_android);

            hierarchy.Configured = true;

            appender_console.ActivateOptions();
            appender_debug.ActivateOptions();
            //appender_trace.ActivateOptions();
            //appender_android.ActivateOptions();

            //global::log4net.Config.BasicConfigurator.Configure(appenders);

            global::log4net.ILog log = null;
            log = global::log4net.LogManager.GetLogger("HolisticWare Logger");

            log.Debug("Debug message HolisticWare Log04()");
            log.Info("Info message HolisticWare Log04()");
            log.Warn("Warning message HolisticWare Log04()");
            log.Error("Error message HolisticWare Log04()");
            log.Fatal("Fatal message HolisticWare Log04()");

            return;
        }
Example #8
0
        public static void Log03()
        {
            global::log4net.Config.BasicConfigurator.Configure();
            global::log4net.ILog log = null;
            log = global::log4net.LogManager
                  .GetLogger("AndroidLogger");

            log.Debug("Debug message HolisticWare Log03()");
            log.Info("Info message HolisticWare Log03()");
            log.Warn("Warning message HolisticWare Log03()");
            log.Error("Error message HolisticWare Log03()");
            log.Fatal("Fatal message HolisticWare Log03()");

            return;
        }
Example #9
0
        public static void Log02()
        {
            global::log4net.Config.BasicConfigurator.Configure();
            global::log4net.ILog log = null;
            log = global::log4net.LogManager
                  .GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            log.Debug("Debug message HolisticWare Log02()");
            log.Info("Info message HolisticWare Log02()");
            log.Warn("Warning message HolisticWare Log02()");
            log.Error("Error message HolisticWare Log02()");
            log.Fatal("Fatal message HolisticWare Log02()");

            return;
        }
Example #10
0
        public static void AddingMultipleAppenders2()
        {
            global::log4net.Tests.Appender.CountingAppender counting =
                new global::log4net.Tests.Appender.CountingAppender();
            global::log4net.Appender.ConsoleAppender console =
                new global::log4net.Appender.ConsoleAppender();

            global::log4net.Config.BasicConfigurator.Configure(counting, console);

            global::log4net.ILog log = global::log4net.LogManager.GetLogger(new LogSamples().GetType());

            log.Debug("Debug message HolisticWare AddingMultipleAppenders2()");
            log.Info("Info message HolisticWare AddingMultipleAppenders2()");
            log.Warn("Warning message HolisticWare AddingMultipleAppenders2()");
            log.Error("Error message HolisticWare AddingMultipleAppenders2()");
            log.Fatal("Fatal message HolisticWare AddingMultipleAppenders2()");

            return;
        }