Example #1
0
 protected void AddLogMessage(
     ILogManager manager,
     LogConfig config,
     LogLevel level,
     string message,
     IDictionary <string, object> properties)
 {
     try
     {
         if (manager == null)
         {
             return;
         }
         if (manager.Disabled)
         {
             return;
         }
         if (config.Enabled == false)
         {
             return;
         }
         if (level == LogLevel.Debug && config.IsDebugEnabled == false)
         {
             return;
         }
         if (level == LogLevel.Trace && config.IsTraceEnabled == false)
         {
             return;
         }
         if (level == LogLevel.Info && config.IsInfoEnabled == false)
         {
             return;
         }
         if (level == LogLevel.Warning && config.IsWarningEnabled == false)
         {
             return;
         }
         if (level == LogLevel.Error && config.IsErrorEnabled == false)
         {
             return;
         }
         if (level == LogLevel.Fatal && config.IsFatalEnabled == false)
         {
             return;
         }
         var mes = new LogMessage()
         {
             Level   = level,
             Message = message
         };
         if (string.IsNullOrEmpty(Context) == false)
         {
             mes.Context = Context;
         }
         if (properties != null)
         {
             mes.Properties = new ExtentionPropertyCollection(properties);
         }
         manager.AddLogMessage(ComponentControl, mes);
     }
     catch (Exception exception)
     {
         var log = ((Client)ComponentControl.Client).InternalLog;
         log.Error("Ошибка добавления лога", exception);
     }
 }