zoukankan      html  css  js  c++  java
  • c# 文件日志处理 需要log4net配置

    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Linq;
    using System.Text;
    
    namespace HuaTong.General.Utility
    {
        /// <summary>
        /// 文件日志处理 需要log4net配置
        /// </summary>
        public static class LogHelper
        {
            static LogHelper()
            {
                log4net.Config.XmlConfigurator.Configure();
            }
    
            private static readonly log4net.ILog loginfo = log4net.LogManager.GetLogger("Logger");
            private static readonly EventLog osEventLog = new EventLog();
            private static readonly log4net.ILog logtrace = log4net.LogManager.GetLogger("LoggerTrace");
            private static readonly log4net.ILog logcallback = log4net.LogManager.GetLogger("LoggerCallback");
    
            /// <summary>
            /// 跟踪日志记录
            /// </summary>
            public static void TraceLog(string info)
            {
                if (logtrace.IsInfoEnabled)
                {
                    logtrace.Info(info);
                }
            }
            /// <summary>
            /// 回调日志记录
            /// </summary>
            public static void CallbackLog(string info)
            {
                if (logcallback.IsInfoEnabled)
                {
                    logcallback.Info(info);
                }
            }
    
            /// <summary>
            /// 操作日志记录
            /// </summary>
            public static void Info(string info)
            {
                if (loginfo.IsInfoEnabled)
                {
                    loginfo.Info(info);
                }
            }
    
            /// <summary>
            /// 错误日志记录
            /// </summary>
            public static void Error(string info, Exception ex = null)
            {
                if (loginfo.IsErrorEnabled)
                {
                    loginfo.Error(info, ex);
                }
            }
        }
    }
  • 相关阅读:
    CString详细讲解
    常用的函数调用约定 stdcall/cdecl/fastcall
    near指针,far指针,huge指针
    md /mdd /ml /mt/mtd
    VC通过ADO链接ORACLE数据库
    c++ 线程同步
    typedef struct与struct的区别
    BeginPaint&&GetDc(转)
    left join 命令详解
    sqlserver IO 监测
  • 原文地址:https://www.cnblogs.com/password1/p/5870747.html
Copyright © 2011-2022 走看看