Exemplo n.º 1
0
        //public void Intercept(IInvocation invocation)
        //{
        //    if (Logger.IsDebugEnabled)
        //        Logger.Debug(CreateInvocationLogString(invocation));
        //    try
        //    {
        //        invocation.Proceed();
        //    }
        //    catch (Exception ex)
        //    {
        //        if (Logger.IsErrorEnabled) Logger.Error(CreateInvocationLogString(invocation), ex);
        //        throw;
        //    }
        //}
        public void Intercept(IInvocation invocation)
        {
            if (!Loggers.ContainsKey(invocation.TargetType))
            {
                Loggers.Add(invocation.TargetType, LoggerFactory.Create(invocation.TargetType));
            }
            ILogger logger = Loggers[invocation.TargetType];

            if (logger.IsDebugEnabled)
            {
                logger.Debug(CreateInvocationLogString(invocation));
            }
            try
            {
                invocation.Proceed();
            }
            catch (Exception ex)
            {
                if (Logger.IsErrorEnabled)
                {
                    Logger.Error(CreateInvocationLogString(invocation), ex);
                }
                throw;
            }
        }
Exemplo n.º 2
0
        public static ILogger Get <T>()
        {
            if (!Loggers.ContainsKey(typeof(T)))
            {
                Loggers.Add(typeof(T), LoggerFactory.CreateLogger <T>());
            }

            return(Loggers[typeof(T)]);
        }
Exemplo n.º 3
0
 public ILogger CreateLogger(string categoryName)
 {
     if (Loggers.ContainsKey(categoryName))
     {
         return(Loggers[categoryName]);
     }
     else
     {
         ILogger customerLogger = new CustomLogger(LogLevel.Error,
                                                   this.CustomLoggerConfiguration);
         Loggers.Add(categoryName, customerLogger);
         return(customerLogger);
     }
 }
Exemplo n.º 4
0
 public static ILogger Get(string key)
 {
     return(!Loggers.ContainsKey(key) ? Loggers["File"] : Loggers[key]);
 }