zoukankan      html  css  js  c++  java
  • nlog的简单使用

    1.nuget 安装 nlog

    2.根目录下(与config同级)添加 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"

    internalLogFile="C:TempNLog.Internal.txt" >

    <variable name="logLayout"
    value="Logger:${logger}${newline}Date:${longdate} Level:${uppercase:${level}}${newline}Message:${message} ${newline}${onexception:Exception:${exception:format=toString}${newline}}" />

    <targets>
    <target name="asyncFile" xsi:type="AsyncWrapper">
    <target name="log_file" xsi:type="File"
    fileName="${basedir}/Logs/${shortdate}/${shortdate}.txt"
    layout="${logLayout}"
    archiveFileName="${basedir}/archives/${shortdate}-{#####}.txt"
    archiveAboveSize="102400"
    archiveNumbering="Sequence"
    concurrentWrites="false"
    keepFileOpen="true"
    encoding="utf-8"
    openFileCacheTimeout="30"/>
    </target>
    </targets>

    <rules>
    <logger name="*" minlevel="Info" writeTo="asyncFile" />
    </rules>
    </nlog>

    3.代码中使用

  • 相关阅读:
    编程为谁?
    Nokia S60编程环境的建立(转自彩酷玩家)
    你可以是一个机器吗?
    无法在web服务器上启动调试的解决
    VB.NET和VB6.0有什么区别(转)
    短信3
    短信2
    短信(转自天极)
    短信4
    函数递归调用
  • 原文地址:https://www.cnblogs.com/mmclog/p/13824726.html
Copyright © 2011-2022 走看看