• NLog简单例子


    引用

    <?xml version="1.0" encoding="utf-8"?>
    <packages>
      <package id="NLog" version="4.5.2" targetFramework="net461" />
      <package id="NLog.Config" version="4.5.2" targetFramework="net461" />
      <package id="NLog.Schema" version="4.5.2" targetFramework="net461" />
    </packages>

    配置NLog.config(要配置:始终复制)

    <?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"
          xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
          autoReload="true"
          throwExceptions="false"
          internalLogLevel="Off" internalLogFile="c:	emp
    log-internal.log">
      <targets>
        <target name="log_file" xsi:type="File" fileName="${basedir}/logs/${shortdate}.log" layout="${longdate} ${uppercase:${level}} ${message}" />
      </targets>
    
      <rules>
        <logger name="*" minlevel="Debug"   writeTo="log_file" />
      </rules>
    </nlog>

     

    测试

        class Program
        {
            private static Logger logger = LogManager.GetCurrentClassLogger();
            static void Main(string[] args)
            {
                logger.Trace("Trace Message");
                logger.Debug("Debug Message");
                logger.Info("Info Message");
                logger.Error("Error Message");   
                logger.Fatal("Fatal Message");
            }
        }

  • 相关阅读:
    TOJ5272: 逆矩阵
    TOJ4537: n阶行列式
    gym101532 2017 JUST Programming Contest 4.0
    Float(浮动)
    块级元素与行级元素
    MyBatis-Oracle生成主键,嵌套对象中的List增加
    MyBatis嵌套对象中的List查询
    dbcp properties
    Idea菜单字体大小调整
    DOM4J
  • 原文地址:https://www.cnblogs.com/lgxlsm/p/8778028.html
Copyright © 2020-2023  润新知