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);
            }
    
    
        }
  • 相关阅读:
    文件上传漏洞之js验证
    文件上传漏洞靶机upload-labs(1到10)
    URI/URL/URN都是什么
    解压jdk报错gzip: stdin: not in gzip format
    burpsuite常见问题
    C/C++字符串反转的N种方法
    转 二叉树之Java实现二叉树基本操作
    MySQL 面试基础
    转 MySQL中的行级锁,表级锁,页级锁
    MySQL问题排查工具介绍
  • 原文地址:https://www.cnblogs.com/jonney-wang/p/13686533.html
Copyright © 2011-2022 走看看