• 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);
                }
            }
        }
    }
  • 相关阅读:
    「ROI 2019 Day1」运输 20/19
    「ROI 2018 Day 2」无进位加法
    「ROI 2018 Day 1」量子隐形传态
    「ROI 2018 Day 2」快速排序
    「ROI 2018 Day 1」Innophone (分块+斜率优化)
    「ROI 2017 Day 1」虎 (计算几何)
    [BJ United Round #3] 押韵 [学习笔记]
    「CEOI2020」象棋世界
    CF1375G
    CF1392(div1+div2)
  • 原文地址:https://www.cnblogs.com/password1/p/5870747.html
Copyright © 2020-2023  润新知