微信搜索superit|邀请体验:大数据, 数据管理、OLAP分析与可视化平台 | 赞助作者:赞助作者

Nlog的使用

 

NLOG

NLOG.EXTENTIOSNS.LOGGING

.net framework用1.0.2

.net core 查文档

创建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">

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

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

    <rules>
        <!--<logger name="*" minlevel="Debug" writeTo="console" />-->
        <logger name="*" minlevel="Debug" writeTo="asyncFile" />
    </rules>
</nlog>

 

 

using NLog;

private static readonly Logger logger = LogManager.GetCurrentClassLogger();

 

https://blog.csdn.net/lijingguang/article/details/139525178

转载请注明:SuperIT » Nlog的使用

喜欢 (0)or分享 (0)

您必须 登录 才能发表评论!