Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1473


Ignore:
Timestamp:
03/31/09 16:32:40 (15 years ago)
Author:
epitzer
Message:

Include exception information in log messages. (#524)

Location:
trunk/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/Core/ConfigurationService.cs

    r1469 r1473  
    5050          customConfigurations[config.Key] = config.Value;
    5151        }
    52       } catch {
    53         Logger.Warn("Could not load settings.");       
     52      } catch (Exception e) {
     53        Logger.Warn("Could not load settings.", e);       
    5454      }
    5555    }
     
    9595            }
    9696            Formatters[formatter.Format].Add(formatter);
    97           } catch (MissingMethodException) {
    98             Logger.Warn("Could not instantiate " + t.VersionInvariantName());           
     97          } catch (MissingMethodException e) {
     98            Logger.Warn("Could not instantiate " + t.VersionInvariantName(), e);           
    9999          }         
    100100        }
     
    102102          try {
    103103            Decomposers.Add((IDecomposer) Activator.CreateInstance(t, true));
    104           } catch (MissingMethodException) {
    105             Logger.Warn("Could not instantiate " + t.VersionInvariantName());           
     104          } catch (MissingMethodException e) {
     105            Logger.Warn("Could not instantiate " + t.VersionInvariantName(), e);           
    106106          }
    107107        }
  • trunk/sources/HeuristicLab.Tracing/HeuristicLab.log4net.xml

    r1470 r1473  
    1010    <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
    1111    <layout type="log4net.Layout.PatternLayout">
    12       <conversionPattern value="%-4timestamp [%appdomain/%thread] %-5level %logger %ndc - %message%newline" />
     12      <conversionPattern value="%-4timestamp [%appdomain/%thread] %-5level %logger %ndc - %message%newline%exception" />
    1313    </layout>
    1414  </appender>
     
    2626    <level value="INFO" />
    2727    <appender-ref ref="BufferingForwardingAppender" />
    28     <appender-ref ref="RollingFileAppender" />
    2928  </root>
    3029 
  • trunk/sources/HeuristicLab.Tracing/Logger.cs

    r1470 r1473  
    2323      XmlConfigurator.ConfigureAndWatch(
    2424        new FileInfo(Settings.Default.log4netConfigFile));
    25       Info("logging initialized");
     25      Info("logging initialized " + DateTime.Now);
    2626    }
    2727
     
    3030      StackFrame frame = new StackFrame(nParents + 1);
    3131      return LogManager.GetLogger(frame.GetMethod().DeclaringType);     
     32    }
     33
     34    public static ILog GetDefaultLogger() {
     35      Configure();
     36      StackFrame frame = new StackFrame(1);
     37      return LogManager.GetLogger(frame.GetMethod().DeclaringType);
    3238    }
    3339
     
    5460    public static void Debug(Type type, object message) {
    5561      Configure();
    56       LogManager.GetLogger(type).Debug(message);     
     62      LogManager.GetLogger(type).Debug(message);
    5763    }
    5864
     
    7783    }
    7884
     85    public static void Debug(object message, Exception exception) {
     86      GetDefaultLogger(1).Debug(message, exception);
     87    }
     88
     89    public static void Info(object message, Exception exception) {
     90      GetDefaultLogger(1).Info(message, exception);
     91    }
     92
     93    public static void Warn(object message, Exception exception) {
     94      GetDefaultLogger(1).Warn(message, exception);
     95    }
     96
     97    public static void Error(object message, Exception exception) {
     98      GetDefaultLogger(1).Error(message, exception);
     99    }
     100
     101    public static void Fatal(object message, Exception exception) {
     102      GetDefaultLogger(1).Fatal(message, exception);
     103    }
     104
     105    public static void Debug(Type type, object message, Exception exception) {
     106      Configure();
     107      LogManager.GetLogger(type).Debug(message, exception);
     108    }
     109
     110    public static void Info(Type type, object message, Exception exception) {
     111      Configure();
     112      LogManager.GetLogger(type).Info(message, exception);
     113    }
     114
     115    public static void Warn(Type type, object message, Exception exception) {
     116      Configure();
     117      LogManager.GetLogger(type).Warn(message, exception);
     118    }
     119
     120    public static void Error(Type type, object message, Exception exception) {
     121      Configure();
     122      LogManager.GetLogger(type).Error(message, exception);
     123    }
     124
     125    public static void Fatal(Type type, object message, Exception exception) {
     126      Configure();
     127      LogManager.GetLogger(type).Fatal(message, exception);
     128    }
     129
    79130  }
    80131}
Note: See TracChangeset for help on using the changeset viewer.