Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
0
    public static ILog GetLoggerByType(Type type)
    {
        global::log4net.ILog log4netLogger =
            global::log4net.LogManager.GetLogger(type);
        ILog logger = new Log4NetLog(log4netLogger);

        return(logger);
    }
Ejemplo n.º 4
0
    public static ILog GetLoggerByName(string name)
    {
        global::log4net.ILog log4netLogger =
            global::log4net.LogManager.GetLogger(name);
        ILog logger = new Log4NetLog(log4netLogger);

        return(logger);
    }
Ejemplo n.º 5
0
    public static ILog GetLoggerByName(string name)
    {
        global::log4net.ILog log4netLogger =
            global::log4net.LogManager.GetLogger(name);
        // Log4NetLog is an implementation of our ILog
        // that accepts a lognet:ILog and delegates to it
        ILog logger = new Log4NetLog(log4netLogger);

        return(logger);
    }
Ejemplo n.º 6
0
        static LogSamples()
        {
            StringAppender            = new global::log4net.Tests.Appender.StringAppender();
            hierarchy_string_appender =
                (global::log4net.Repository.Hierarchy.Hierarchy)
                global::log4net.LogManager.GetRepository();
            hierarchy_string_appender.Root.AddAppender(StringAppender);
            LogForStringAppender = global::log4net.LogManager.GetLogger("LogForStringAppender");

            InitFileLogs();

            return;
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 8
0
		static LogSamples()
		{

			StringAppender = new global::log4net.Tests.Appender.StringAppender();
			hierarchy_string_appender =
				(global::log4net.Repository.Hierarchy.Hierarchy)
					global::log4net.LogManager.GetRepository();
			hierarchy_string_appender.Root.AddAppender(StringAppender);
			LogForStringAppender = global::log4net.LogManager.GetLogger("LogForStringAppender");

			InitFileLogs();

			return;
		}
Ejemplo n.º 9
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;
        }
Ejemplo n.º 10
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;
        }
Ejemplo n.º 11
0
        public static void InitFileLogs()
        {
            root_folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
            file        = System.IO.Path.Combine(LogSamples.root_folder, "log4net-file.log");
            file_copy   = file + ".txt";

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

            FileAppender        = new global::log4net.Appender.FileAppender();
            FileAppender.File   = System.IO.Path.Combine(root_folder, "log4net-file.log");
            FileAppender.Layout = layout;
            FileAppender.ActivateOptions();
            global::log4net.Config.BasicConfigurator.Configure(FileAppender);

            RollingFileAppender        = new global::log4net.Appender.RollingFileAppender();
            RollingFileAppender.File   = System.IO.Path.Combine(root_folder, "log4net-file-rolling.log");
            RollingFileAppender.Layout = layout;
            RollingFileAppender.ActivateOptions();
            global::log4net.Config.BasicConfigurator.Configure(RollingFileAppender);

            global::log4net.Appender.AppenderCollection appenders =
                new global::log4net.Appender.AppenderCollection();
            appenders.Add(FileAppender);
            appenders.Add(RollingFileAppender);

            hierarchy_file =
                (global::log4net.Repository.Hierarchy.Hierarchy)
                global::log4net.LogManager.GetRepository();
            hierarchy_file.Root.AddAppender(FileAppender);
            hierarchy_file.Root.AddAppender(RollingFileAppender);

            //configure the logging at the root.
            hierarchy_file.Root.Level = global::log4net.Core.Level.All;


            //mark repository as configured and
            //notify that is has changed.
            hierarchy_file.Root.Repository.Configured = true;
            hierarchy_file.Configured = true;
            hierarchy_file.RaiseConfigurationChanged(EventArgs.Empty);

            LogForFiles = global::log4net.LogManager.GetLogger("LogForFiles");
            //LogForFiles.Logger.Repository.ResetConfiguration();


            int a = hierarchy_file.Root.Appenders.Count;
        }
Ejemplo n.º 12
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;
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Log4NetLogger"/> class.
 /// </summary>
 /// <param name="inner">The actual log4net logger.</param>
 /// <exception cref="ArgumentNullException">Log4Net logger not passed.</exception>
 public Log4NetLogger(global::log4net.ILog inner)
 {
     _inner = inner ?? throw new ArgumentNullException(nameof(inner));
 }
Ejemplo n.º 14
0
		public static void InitFileLogs()
		{
			root_folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
			file = System.IO.Path.Combine(LogSamples.root_folder, "log4net-file.log");
			file_copy = file + ".txt";

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

			FileAppender = new global::log4net.Appender.FileAppender();
			FileAppender.File = System.IO.Path.Combine(root_folder, "log4net-file.log");
			FileAppender.Layout = layout;
			FileAppender.ActivateOptions();
			global::log4net.Config.BasicConfigurator.Configure(FileAppender);

			RollingFileAppender = new global::log4net.Appender.RollingFileAppender();
			RollingFileAppender.File = System.IO.Path.Combine(root_folder, "log4net-file-rolling.log");
			RollingFileAppender.Layout = layout;
			RollingFileAppender.ActivateOptions();
			global::log4net.Config.BasicConfigurator.Configure(RollingFileAppender);

			global::log4net.Appender.AppenderCollection appenders =
					new global::log4net.Appender.AppenderCollection();
			appenders.Add(FileAppender);
			appenders.Add(RollingFileAppender);

			hierarchy_file =
				(global::log4net.Repository.Hierarchy.Hierarchy)
					global::log4net.LogManager.GetRepository();
			hierarchy_file.Root.AddAppender(FileAppender);
			hierarchy_file.Root.AddAppender(RollingFileAppender);

			//configure the logging at the root.  
			hierarchy_file.Root.Level = global::log4net.Core.Level.All;


			//mark repository as configured and  
			//notify that is has changed.  
			hierarchy_file.Root.Repository.Configured = true;
			hierarchy_file.Configured = true;
			hierarchy_file.RaiseConfigurationChanged(EventArgs.Empty);

			LogForFiles = global::log4net.LogManager.GetLogger("LogForFiles");
			//LogForFiles.Logger.Repository.ResetConfiguration();


			int a = hierarchy_file.Root.Appenders.Count;
		}
Ejemplo n.º 15
0
 public void InitializeFor(string loggerName)
 {
     log4net.Config.XmlConfigurator.Configure();
     _logger = log4net.LogManager.GetLogger(loggerName);
 }
Ejemplo n.º 16
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="AbbotwareLogger" /> class.
 /// </summary>
 /// <param name="log">Log4net's ILog</param>
 /// <param name="factory">logger factory</param>
 public AbbotwareLogger(Log4netILog log, AbbotwareLoggerFactory factory)
     : this(log.Logger, factory)
 {
 }
 public void InitializeFor(string loggerName)
 {
     _logger = LogManager.GetLogger(loggerName);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Log4NetLogger"/> class.
 /// </summary>
 /// <param name="inner">The actual log4net logger.</param>
 /// <exception cref="ArgumentNullException">Log4Net logger not passed.</exception>
 public Log4NetLogger(global::log4net.ILog inner)
 {
     _inner = inner ?? throw new ArgumentNullException(nameof(inner));
     SetLogLevel();
     _inner.Logger.Repository.ConfigurationChanged += OnInnerLoggerReconfigured;
 }