c#Log4Helper类

 /// 
    /// 方法中的优先级从0.0-4.0从高到低
    /// 
    public static class Log4Helper
    {
        /// 
        ///0.0 指定非常严重的错误事件,这可能导致应用程序中止
        /// 
        /// 
        /// 
        /// 
        public static void Fatal(Type type, object message, Exception exception = null)
        {
            ILog log = LogManager.GetLogger(type);
            if (exception == null)
                log.Fatal(message);
            else
                log.Fatal(message, exception);
        }
        /// 
        /// 1.0错误事件可能仍然允许应用程序继续运行
        /// 
        /// 
        /// 
        /// 
        public static void Error(Type type, object message, Exception exception = null)
        {
            ILog log = LogManager.GetLogger(type);
            if (exception == null)
                log.Error(message);
            else
                log.Error(message, exception);
        }
        /// 
        /// 2.0指定具有潜在危害的情况指定具有潜在危害的情况
        /// 
        /// 
        /// 
        /// 
        public static void Warn(Type type, object message, Exception exception = null)
        {
            ILog log = LogManager.GetLogger(type);
            if (exception == null)
                log.Warn(message);
            else
                log.Warn(message, exception);
        }
        /// 
        /// 3.0指定能够突出在粗粒度级别的应用程序运行情况的信息的消息
        /// 
        /// 
        /// 
        /// 
        public static void Info(Type type, object message, Exception exception = null)
        {
            ILog log = LogManager.GetLogger(type);
            if (exception == null)
                log.Info(message);
            else
                log.Info(message, exception);
        }
        /// 
        /// 4.0指定细粒度信息事件是最有用的应用程序调试
        /// 
        /// 
        /// 
        /// 
        public static void Debug(Type type, object message, Exception exception = null)
        {
            ILog log = LogManager.GetLogger(type);
            if (exception == null)
                log.Debug(message);
            else
                log.Debug(message, exception);
        }

 

你可能感兴趣的:(常见问题)