Example #1
0
        /// <summary>
        /// Initializes log4net to log to a memory appender which can then be referenced
        /// </summary>
        public Logging(log4net.Core.Level level = null)
        {
            Logger.Level = level ?? log4net.Core.Level.All;

            Logger.RemoveAllAppenders();
            Logger.AddAppender(MemoryAppender);

            Logger.Repository.Configured = true;

            Log.Initialize(new Logger());
        }
Example #2
0
        private static void RemoveAllAppender(string loggerName)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(loggerName);
            log4net.Repository.Hierarchy.Logger l = (log4net.Repository.Hierarchy.Logger)log.Logger;

            l.RemoveAllAppenders();
        }
Example #3
0
 private void RemoveAllAppender()
 {
     try
     {
         log4net.Repository.Hierarchy.Logger l = (log4net.Repository.Hierarchy.Logger)_log.Logger;
         l.RemoveAllAppenders();
     }
     catch (Exception ex)
     {
         AppUtil.LogEvent(ex.ToString(), System.Diagnostics.EventLogEntryType.Error);
     }
 }
Example #4
0
        public static XMightLogger GerLoggerForName(String pName, String pHeader = null)
        {
            ILog logger = log4net.LogManager.GetLogger(pName);

            log4net.Repository.Hierarchy.Logger l = (log4net.Repository.Hierarchy.Logger)logger.Logger;
            l.RemoveAllAppenders();

            DateFolderRollingFileAppender app1 = new DateFolderRollingFileAppender();

            app1.Name = pName + "Appender";
            app1.File = "logs\\" + pName;
            app1.PreserveLogFileNameExtension = true;
            app1.DatePattern       = ".dd-MM-yyyy";
            app1.AppendToFile      = false;
            app1.ImmediateFlush    = true;
            app1.RollingStyle      = log4net.Appender.RollingFileAppender.RollingMode.Date;
            app1.StaticLogFileName = false;

            log4net.Layout.PatternLayout layout = new log4net.Layout.PatternLayout();
            layout.ConversionPattern = "%d{dd-MM-yyyy HH:mm:ss.fff}\t%timestamp\t%message%newline";

            if (!String.IsNullOrEmpty(pHeader))
            {
                layout.Header = pHeader + "\n";
            }

            layout.ActivateOptions();

            app1.Layout = layout;
            app1.ActivateOptions();

            l.AddAppender(app1);
            l.Additivity = false;
            l.Level      = log4net.Core.Level.Debug;

            return(new XMightLogger(logger));
        }
Example #5
0
        private void RemoveAllAppender(log4net.ILog log)
        {
            log4net.Repository.Hierarchy.Logger l = (log4net.Repository.Hierarchy.Logger)log.Logger;

            l.RemoveAllAppenders();
        }