关闭

log4

259人阅读 评论(0) 收藏 举报
分类:

1

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace USALibrary.Common
{
    /// <summary>
    /// log4net日志辅助类
    /// </summary>
    public class Logging
    {
        public static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        /// <summary>
        /// 致命错误信息
        /// </summary>
        /// <param name="strMsg"></param>
        public static void Fatal(string strMsg)
        {
            log.Fatal(strMsg);
        }

        /// <summary>
        /// 致命错误信息
        /// </summary>
        /// <param name="ex">Exception</param>
        public static void Fatal(Exception ex)
        {
            log.Fatal(ex.ToString());
        }

        /// <summary>
        /// 错误信息
        /// </summary>
        /// <param name="strMsg"></param>
        public static void Error(string strMsg)
        {
            log.Error(strMsg);
        }

        /// <summary>
        /// 错误信息
        /// </summary>
        /// <param name="strMsg">Exception</param>
        public static void Error(Exception ex)
        {
            log.Error(ex.ToString());
        }

        /// <summary>
        /// 警告信息
        /// </summary>
        /// <param name="strMsg"></param>
        public static void Warn(string strMsg)
        {
            log.Warn(strMsg);
        }

        /// <summary>
        /// 警告信息
        /// </summary>
        /// <param name="ex">Exception</param>
        public static void Warn(Exception ex)
        {
            log.Warn(ex.ToString());
        }

        /// <summary>
        /// 调试信息
        /// </summary>
        /// <param name="strMsg"></param>
        public static void Debug(string strMsg)
        {
            log.Debug(strMsg);
        }

        /// <summary>
        /// 调试信息
        /// </summary>
        /// <param name="ex">Exception</param>
        public static void Debug(Exception ex)
        {
            log.Debug(ex.ToString());
        }

        /// <summary>
        /// 一般信息
        /// </summary>
        /// <param name="strMsg"></param>
        public static void Info(string strMsg)
        {
            log.Info(strMsg);
        }

        /// <summary>
        /// 一般信息
        /// </summary>
        /// <param name="strMsg">Exception</param>
        public static void Info(Exception ex)
        {
            log.Info(ex.ToString());
        }

        /// <summary>
        /// 初始化log4net配置
        /// </summary>
        public static void InitLog()
        {
            log4net.Config.XmlConfigurator.Configure();
        }
    }
}


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:798636次
    • 积分:12526
    • 等级:
    • 排名:第1273名
    • 原创:469篇
    • 转载:26篇
    • 译文:2篇
    • 评论:73条
    最新评论