zoukankan      html  css  js  c++  java
  • NLog

    <?xml version="1.0" encoding="utf-8" ?>
    <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          autoReload="true">
        <targets>
            <target name="file" xsi:type="AsyncWrapper" queueLimit="5000" overflowAction="Discard">
                <target xsi:type="File" fileName="${basedir}/logs/${Logger}/${shortdate}.log" 
                        layout="${level}--------------------${longdate}${newline}${message}${newline}" />
            </target>
        </targets>
        <rules>
            <logger name="*" minlevel="Debug" writeTo="file" />
        </rules>
    </nlog>
        public static class LogUtil
        {
            static LogUtil()
            {
                NLog.LogManager.Configuration = new NLog.Config.XmlLoggingConfiguration(Path.GetDirectoryName(typeof(LogUtil).Assembly.Location) + "\nlog.config");
            }
    
            private static NLog.ILogger GetLogger(string loggerName)
            {
                return NLog.LogManager.GetLogger(loggerName);
            }
    
            private static NLog.ILogger _normalLogger = GetLogger("Normal");
            private static NLog.ILogger _errorLogger = GetLogger("Exception");
    
            public static void LogDebug(this string msg)
            {
                _normalLogger.Debug(msg);
            }
    
            public static void LogInfo(this string info)
            {
                _normalLogger.Info(info);
            }
    
            public static void LogWarn(this string warn)
            {
                _normalLogger.Warn(warn);
            }
    
            public static void LogError(this Exception error, string extendMsg="")
            {
                _errorLogger.Error(extendMsg + Environment.NewLine + error.Message + Environment.NewLine + error.StackTrace);
            }
    
    
        }
  • 相关阅读:
    C#异步调用的好处和方法
    asp.net运行原理
    基于jQuery的AJAX和JSON的实例
    Slq Server创建索引
    SQL查询一个表中类别字段中Max()最大值对应的记录
    优化SQL Server的内存占用之执行缓存
    ASP.NET缓存
    .NET Framework 4.5新特性
    ADO.NET 连接数据库字符串(Oracle、SqlServer、Access、ODBC)
    sql server基础
  • 原文地址:https://www.cnblogs.com/jonney-wang/p/13686533.html
Copyright © 2011-2022 走看看