public void TearDown()
 {
     if (logger != null)
     {
         logger.Dispose();
     }
 }
Esempio n. 2
0
 void MvcApplication_EndRequest(object sender, EventArgs e)
 {
     try
     {
         var loggerName = Convert.ToString(HttpContext.Current.Items["LoggerName"]);
         if (!string.IsNullOrEmpty(loggerName))
         {
             var rule = LogManager.Configuration.LoggingRules.Where(x => x.NameMatches(loggerName)).FirstOrDefault();
             if (rule != null && rule.Targets.Count > 0)
             {
                 MemoryTarget target = rule.Targets.Where(x => x.Name == _loggerName).FirstOrDefault() as MemoryTarget;
                 if (target != null)
                 {
                     target.Dispose();
                     LogManager.Configuration.LoggingRules.Remove(rule);
                     LogManager.Configuration.RemoveTarget(target.Name);
                     LogManager.Configuration.Reload();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         LogEventInfo info = new LogEventInfo(LogLevel.Error, ECMSSettings.DEFAULT_LOGGER, ex.ToString());
         ECMSLogger.Instance.Log(info);
     }
 }
Esempio n. 3
0
        protected override void OnShown(EventArgs e)
        {
            SearchUpdates();
            if (_memoryLogger.Logs.Count > 0)
            {
                LogRichTextBox.Text =
                    _memoryLogger.Logs.Aggregate(new StringBuilder(), (x, y) => x.AppendLine(y)).ToString();
            }

            LogManager.Configuration.LoggingRules.Remove(_loggingRule);
            _memoryLogger.Dispose();

            _memoryLogger = null;
            _loggingRule  = null;

            var target = new RichTextBoxTarget
            {
                Layout      = Program.LogLayout,
                ControlName = "LogRichTextBox",
                FormName    = Name,
                AutoScroll  = true,
                CreatedForm = false,
                Name        = "textBox"
            };

            target.RowColoringRules.Add(new RichTextBoxRowColoringRule("level == LogLevel.Debug", "Gray", "White"));
            target.RowColoringRules.Add(new RichTextBoxRowColoringRule("level == LogLevel.Info", "Black", "White"));
            target.RowColoringRules.Add(new RichTextBoxRowColoringRule("level == LogLevel.Warn", "DarkRed", "White"));
            target.RowColoringRules.Add(new RichTextBoxRowColoringRule("level == LogLevel.Error", "White", "DarkRed",
                                                                       FontStyle.Bold));
            target.RowColoringRules.Add(new RichTextBoxRowColoringRule("level == LogLevel.Fatal", "Yellow", "DarkRed",
                                                                       FontStyle.Bold));

            SimpleConfigurator.ConfigureForTargetLogging(target, Program.MinLogLevel);
        }
Esempio n. 4
0
 public void Dispose()
 {
     if (_memoryTarget != null)
     {
         _memoryTarget.Dispose();
     }
 }
Esempio n. 5
0
 public void Cleanup()
 {
     _logger = null;
     _memoryTarget.Dispose();
 }
Esempio n. 6
0
 public void Dispose()
 {
     _loggerFactory.Dispose();
     _inMemoryLogs.Dispose();
 }