log4net辅助类

直接用log4net还是不太方便,写下作以后的参考:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Util
{
    /// <summary>
    /// Author     : yenange
    /// Date       : 2014-02-21
    /// Description: 日志辅助类
    /// </summary>
    public sealed class Logger
    {
        #region [ 单例模式 ]
        private static readonly Logger _logger = new Logger();
        private static readonly log4net.ILog _Logger4net = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        /// <summary>
        /// 无参私有构造函数
        /// </summary>
        private Logger()
        {
        }

        /// <summary>
        /// 得到单例
        /// </summary>
        public static Logger Singleton
        {
            get
            {
                return _logger;
            }
        }
        #endregion

        #region [ 参数 ]
        public bool IsDebugEnabled
        {
            get { return _Logger4net.IsDebugEnabled; }
        }
        public bool IsInfoEnabled
        {
            get { return _Logger4net.IsInfoEnabled; }
        }
        public bool IsWarnEnabled
        {
            get { return _Logger4net.IsWarnEnabled; }
        }
        public bool IsErrorEnabled
        {
            get { return _Logger4net.IsErrorEnabled; }
        }
        public bool IsFatalEnabled
        {
            get { return _Logger4net.IsFatalEnabled; }
        }
        #endregion

        #region [ 接口方法 ]

        #region [ Debug ]
        public void Debug(string message)
        {
            if (this.IsDebugEnabled)
            {
                this.Log(LogLevel.Debug, message);
            }
        }

        public void Debug(string message, Exception exception)
        {
            if (this.IsDebugEnabled)
            {
                this.Log(LogLevel.Debug, message, exception);
            }
        }

        public void DebugFormat(string format, params object[] args)
        {
            if (this.IsDebugEnabled)
            {
                this.Log(LogLevel.Debug, format, args);
            }
        }

        public void DebugFormat(string format, Exception exception, params object[] args)
        {
            if (this.IsDebugEnabled)
            {
                this.Log(LogLevel.Debug, string.Format(format, args), exception);
            }
        }
        #endregion

        #region [ Info ]
        public void Info(string message)
        {
            if (this.IsInfoEnabled)
            {
                this.Log(LogLevel.Info, message);
            }
        }

        public void Info(string message, Exception exception)
        {
            if (this.IsInfoEnabled)
            {
                this.Log(LogLevel.Info, message, exception);
            }
        }

        public void InfoFormat(string format, params object[] args)
        {
            if (this.IsInfoEnabled)
            {
                this.Log(LogLevel.Info, format, args);
            }
        }

        public void InfoFormat(string format, Exception exception, params object[] args)
        {
            if (this.IsInfoEnabled)
            {
                this.Log(LogLevel.Info, string.Format(format, args), exception);
            }
        }
        #endregion

        #region  [ Warn ]

        public void Warn(string message)
        {
            if (this.IsWarnEnabled)
            {
                this.Log(LogLevel.Warn, message);
            }
        }

        public void Warn(string message, Exception exception)
        {
            if (this.IsWarnEnabled)
            {
                this.Log(LogLevel.Warn, message, exception);
            }
        }

        public void WarnFormat(string format, params object[] args)
        {
            if (this.IsWarnEnabled)
            {
                this.Log(LogLevel.Warn, format, args);
            }
        }

        public void WarnFormat(string format, Exception exception, params object[] args)
        {
            if (this.IsWarnEnabled)
            {
                this.Log(LogLevel.Warn, string.Format(format, args), exception);
            }
        }
        #endregion

        #region  [ Error ]

        public void Error(string message)
        {
            if (this.IsErrorEnabled)
            {
                this.Log(LogLevel.Error, message);
            }
        }

        public void Error(string message, Exception exception)
        {
            if (this.IsErrorEnabled)
            {
                this.Log(LogLevel.Error, message, exception);
            }
        }

        public void ErrorFormat(string format, params object[] args)
        {
            if (this.IsErrorEnabled)
            {
                this.Log(LogLevel.Error, format, args);
            }
        }

        public void ErrorFormat(string format, Exception exception, params object[] args)
        {
            if (this.IsErrorEnabled)
            {
                this.Log(LogLevel.Error, string.Format(format, args), exception);
            }
        }
        #endregion

        #region  [ Fatal ]

        public void Fatal(string message)
        {
            if (this.IsFatalEnabled)
            {
                this.Log(LogLevel.Fatal, message);
            }
        }

        public void Fatal(string message, Exception exception)
        {
            if (this.IsFatalEnabled)
            {
                this.Log(LogLevel.Fatal, message, exception);
            }
        }

        public void FatalFormat(string format, params object[] args)
        {
            if (this.IsFatalEnabled)
            {
                this.Log(LogLevel.Fatal, format, args);
            }
        }

        public void FatalFormat(string format, Exception exception, params object[] args)
        {
            if (this.IsFatalEnabled)
            {
                this.Log(LogLevel.Fatal, string.Format(format, args), exception);
            }
        }
        #endregion
        #endregion

        #region [ 内部方法 ]
        /// <summary>
        /// 输出普通日志
        /// </summary>
        /// <param name="level"></param>
        /// <param name="format"></param>
        /// <param name="args"></param>
        private void Log(LogLevel level, string format, params object[] args)
        {
            switch (level)
            {
                case LogLevel.Debug:
                    _Logger4net.DebugFormat(format, args);
                    break;
                case LogLevel.Info:
                    _Logger4net.InfoFormat(format, args);
                    break;
                case LogLevel.Warn:
                    _Logger4net.WarnFormat(format, args);
                    break;
                case LogLevel.Error:
                    _Logger4net.ErrorFormat(format, args);
                    break;
                case LogLevel.Fatal:
                    _Logger4net.FatalFormat(format, args);
                    break;
            }
        }

        /// <summary>
        /// 格式化输出异常信息
        /// </summary>
        /// <param name="level"></param>
        /// <param name="message"></param>
        /// <param name="exception"></param>
        private void Log(LogLevel level, string message, Exception exception)
        {
            switch (level)
            {
                case LogLevel.Debug:
                    _Logger4net.Debug(message, exception);
                    break;
                case LogLevel.Info:
                    _Logger4net.Info(message, exception);
                    break;
                case LogLevel.Warn:
                    _Logger4net.Warn(message, exception);
                    break;
                case LogLevel.Error:
                    _Logger4net.Error(message, exception);
                    break;
                case LogLevel.Fatal:
                    _Logger4net.Fatal(message, exception);
                    break;
            }
        }
        #endregion
    }//end of class

    #region [ enum: LogLevel ]
    /// <summary>
    /// 日志级别
    /// </summary>
    public enum LogLevel
    {
        Debug,
        Info,
        Warn,
        Error,
        Fatal
    }
    #endregion
}//end of namespace


ExtJs简介: Extjs在经过两年的发展,Ext JS从2.0版开始,越来越受用户欢迎,今年,Extjs不但推出3.0版本,而且还推出了Ext Core,准备在Web2.0网站开发中占一席之地,如在 Extjs2.x版本中为人所诟病的速度问题在ExtJs3.0中有所改善。不过,最革命性的改变还是ExtJs中新增的Ext.Direct功能,它实现了服务器端的无关性。 在3.2版本中,Ext将增加移动组件,进军移动市场,这将是一次革命性的改进,同时在4.0版本中,除了对HTML5的支持外,还增加画布功能。 还有一点更值得期待,就是Ext的RAD开发工具也在开发当中。估计在不久之后,也可以向VB,C#一样,通过可视化工具拖拽方式即可轻松开发Web应用。 ExtJs在发展过程中不仅一步步地巩固着自己在HTML、CSS、JavaScript领域无可比拟的优势,而且已经开始向相关领域发展扩张。如从2.02版开始为Adobe的RIA技术AIR提供支持,并且为GWT开发了Ext GWT2.0,这些都体现了ExtJs的强大活力和生命力。 在可预见的未来,ExtJs将会甩开对手,大踏步向前。 ExtJs的前景: ExtJS的前景是非常好的,现在的QQ2009的登录界面以及使用,迅雷最新版的主界面,都能够找到这个框架的踪迹。web QQ也是有一个技术版本是使用这种框架的,所以,可以看出,extjs的应用,是越来越广泛了,extjs的前景,不可估量,不论站在技术开发的层次还是大部分用户的使用体验。 国讯教育通用智能OA办公系统项目培训目标 本系列讲座分为四大部分: 1、ExtJs基础篇:主要介绍Ext Core的一些核心功能 2、ExtJs进阶篇:主要介绍ExtJs里的常用组件,容器及布局 3、ExtJs数据篇:主要介绍和数据库交互的相关组件及CRUD功能 4、项目实战篇: Extjs3.2+ASP.NET七层架构+设计模式+ log4j+WebSerice等技术国讯教育通用智能OA办公平台 适用对象 1、要求有一定的javascript语言和HTML,CSS基础的学员 2、有一定的Asp.net网页编程基础和C#语言基础 3、有志于从事富客户端技术ExtJs的学习与研究的学生及专业Web开发人员 模块介绍 1、ExtJs基础篇-ExtJs快速入门 1.1、ExtJs基础篇(1):ExtJs概述与环境配置及架构剖析 1.2、ExtJs基础篇(2):ExtJs OOP基础 1.3、ExtJs基础篇(3):ExtJs 核心函数简介 1.4、ExtJs基础篇(4):ExtJs中的模板详解(1) 1.5、ExtJs基础篇(5):ExtJs中的模板详解(2) 2、ExtJs进阶篇:Extjs进阶 2.1、大话ExtJs中的布局 2.2、ExtJs的常见组件 2.3、ExtJs中的面板及Window窗口 2.4、ExtJs中的选项卡面板 2.5、ExtJs中的对话框与Combox组件 2.6、ExtJs中的ExtTree详解 3、ExtJs数据篇 3.1、数据存储基本单元Record与DataField详解 3.2、数据存储Store详解1 3.3、数据存储Store详解2 3.4、数据代理DataProxy详解 3.5、数据读取器DataReader详解 3.6、Ext.Direct详解1 3.7、Ext.Direct详解2 4、ExtJs实战篇—国讯教育通用智能OA办公平台 (共70讲) 4.1、系统业务流程主功能结构分析 4.2、数据库设计 4.3、抽象工厂+反射七层架构设计 4.4、首页布局设计 4.5、人事管理模块分析设计 4.6、个人专区模块分析设计 4.7、日程管理区模块分析设计 4.8、文档管理模块分析设计 4.9、工单管理模块分析设计 4.10、工资管理模块分析设计 4.11、内部邮箱模块分析设计 4.12、系统管理模块分析设计 4.13、考勤管理模块分析设计 4.14、消息管理模块分析设计 4.15、日志管理 4.16、报表打印及数据统计 4.17、数据导入导出管理 本项目所涉及到的技术: 数据库方面: 1、PD数据库建模 2、SQL Server2005视图、存储过程、用户自定义函数、触发器 ASP.net方面: 1、ASP.net PetShop七层架构 2、抽象工厂+反射+配置文件实现数据库无缝切换 3、序列化/反序列化+泛型集合的应用 4、利用ASP.net HttpHandler实现防盗链 5、网站安全性方面:ASP.net防SQL注入及Web Service Soap头加密技术 6、AS
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值