Ejemplo n.º 1
0
        private static IAppender CreateConsoleAppender(LogMessage.SeverityType severity)
        {
            var appender = new ColoredConsoleAppender();
            appender.AddMapping(new ColoredConsoleAppender.LevelColors {
                ForeColor = ColoredConsoleAppender.Colors.Red,
                Level = Level.Error,
            });
            appender.AddMapping(new ColoredConsoleAppender.LevelColors {
                ForeColor = ColoredConsoleAppender.Colors.Green,
                Level = Level.Debug,
            });
            appender.AddMapping(new ColoredConsoleAppender.LevelColors {
                ForeColor = ColoredConsoleAppender.Colors.White,
                Level = Level.Info,
            });

            appender.Layout = new PatternLayout(LogPattern);
            appender.Name = "Console";
            appender.Threshold = TranslateLevel(severity);
            appender.ActivateOptions();

            var filter = new LoggerMatchFilter {AcceptOnMatch = false, LoggerToMatch = "NHibernate"};
            appender.AddFilter(filter);
            filter = new LoggerMatchFilter {AcceptOnMatch = false, LoggerToMatch = "NHibernate.SQL"};
            appender.AddFilter(filter);

            return appender;
        }
 public void LogVersionOneConfiguration(LogMessage.SeverityType severity, XmlElement config) {
     try {
         var entity = VersionOneSettings.FromXmlElement(config);
         Log(severity, "    VersionOne URL: " + entity.Url);
         Log(severity, string.Format("    Using proxy server: {0}, Integrated authentication: {1}", entity.ProxySettings != null && entity.ProxySettings.Enabled, entity.IntegratedAuth));
     } catch(Exception ex) {
         Log(LogMessage.SeverityType.Warning, "Failed to log VersionOne configuration data.", ex);
     }
 }
        private void Log(LogMessage message) {
            switch(message.Severity) {
                case LogMessage.SeverityType.Debug:
                    Logger.Debug(message.Message, message.Exception);
                    return;

                case LogMessage.SeverityType.Info:
                    Logger.Info(message.Message, message.Exception);
                    return;

                case LogMessage.SeverityType.Warning:
                    Logger.Warn(message.Message, message.Exception);
                    break;

                case LogMessage.SeverityType.Error:
                    Logger.Error(message.Message, message.Exception);
                    return;

                default:
                    Logger.FatalFormat("Log level {0} is not supported", message.Severity);
                    return;
            }
        }
        private IAppender CreateRollingFileAppender(LogMessage.SeverityType severity, string filename, string maxFileSize) {
            var appender = new RollingFileAppender {
                Layout = new PatternLayout(LogPattern),
                Name = "File",
                Threshold = TranslateLevel(severity),
                AppendToFile = true,
                File = filename,
                LockingModel = new FileAppender.MinimalLock(),
                MaximumFileSize = maxFileSize
            };
            appender.ActivateOptions();

            return appender;
        }
 private LogMessage.SeverityType ResolveSeverity(LogMessage.SeverityType originalSeverity) {
     return TreatErrorsAsWarnings && originalSeverity == LogMessage.SeverityType.Error
         ? LogMessage.SeverityType.Warning
         : originalSeverity;
 }
 protected void Log(LogMessage.SeverityType severity, string message, Exception ex) {
     var resultingSeverity = ResolveSeverity(severity);
     Logger.Log(resultingSeverity, message, ex);
 }
 public void LogVersionOneConnectionInformation(LogMessage.SeverityType severity, string metaVersion, string memberOid, string defaultMemberRole) {
     Log(severity, "    VersionOne Meta version: " + metaVersion);
     Log(severity, "    VersionOne Member OID: " + memberOid);
     Log(severity, "    VersionOne Member default role: " + defaultMemberRole);
 }
Ejemplo n.º 8
0
 public void Log(LogMessage.SeverityType severity, string message)
 {
 }
 public void Log(LogMessage.SeverityType severity, string message) {
     Log(severity, message, null);
 }
 public static void MaybeLog(this ILogger logger, LogMessage.SeverityType severity, string message) {
     if(logger != null) {
         logger.Log(severity, message);
     }
 }
Ejemplo n.º 11
0
 public void Log(LogMessage.SeverityType severity, string message, Exception exception)
 {
     Console.WriteLine(string.Format("[{0}] {1}", severity, message), exception);
 }
Ejemplo n.º 12
0
 public void LogVersionOneConnectionInformation(LogMessage.SeverityType severity, string metaVersion, string memberOid, string defaultMemberRole)
 {
 }
Ejemplo n.º 13
0
 public void LogVersionOneConfiguration(LogMessage.SeverityType severity, XmlElement config)
 {
 }
Ejemplo n.º 14
0
 public void Log(LogMessage.SeverityType severity, string message, Exception exception)
 {
 }
 private static Level TranslateLevel(LogMessage.SeverityType severity) {
     switch(severity) {
         case LogMessage.SeverityType.Debug:
             return Level.Debug;
         case LogMessage.SeverityType.Info:
             return Level.Info;
         case LogMessage.SeverityType.Error:
             return Level.Error;
         default:
             return Level.Info;
     }
 }
 public void Log(LogMessage.SeverityType severity, string message, Exception exception) {
     eventManager.Publish(new LogMessage(severity, message, exception));
 }
 protected void Log(LogMessage.SeverityType severity, string message) {
     var resultingSeverity = TreatErrorsAsWarnings && severity == LogMessage.SeverityType.Error
                                 ? LogMessage.SeverityType.Warning
                                 : severity;
     Logger.Log(resultingSeverity, message);
 }