研究一下Log4Net的架构及应用。 执行过程1 LoggingService.Debug(string.Format(“{0}-{1}”, msg.MessageType, msg.Operate));
2 Service.Debug(message);
3 sealed class log4netLoggingService : ILoggingService :
log.Debug(message);
4 LogImpl:
Logger.Log(ThisDeclaringType, m_levelDebug, message, null);
5 Logger.cs:
virtual public void Log(Type callerStackBoundaryDeclaringType, Level level, object message, Exception exception)
{
try
{
if (IsEnabledFor(level))
{
ForcedLog((callerStackBoundaryDeclaringType != null) ? callerStackBoundaryDeclaringType : declaringType, level, message, exception);
}
}
catch (Exception ex)
{
log4net.Util.LogLog.Error(declaringType, “Exception while logging”, ex);
}
}
6 ForcedLog
ForcedLog((callerStackBoundaryDeclaringType != null) ? callerStackBoundaryDeclaringType : declaringType, level, message, exception); 7 Logger.cs
CallAppenders 8 LoggingEvent
private ILoggerRepository m_repository = null;
|