• .net core 使用 Nlog 集成 exceptionless 配置文件


    nlog.config文件

    安装nuget包:

    NLog.Web.AspNetCore

    Exceptionless.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"
    internalLogLevel="Info"
    internalLogFile="Logs/nlog.log">
    <extensions>
    <add assembly="Exceptionless.NLog"/>
    <add assembly="NLog.Web.AspNetCore"/>
    </extensions>
      <targets async="true">

    <target xsi:type="File" name="errorLogFileTarget" fileName="${basedir}/Logs/nlogs/errors/${shortdate}.log"
    layout="${longdate} ${logger} ${uppercase:${level}} ${message} ${newline} ${exception:format=ToString}" />
    <target xsi:type="File" name="infoLogFileTarget" fileName="${basedir}/Logs/nlogs/infos/${shortdate}.log"
    layout="${longdate} ${logger} ${uppercase:${level}} ${message}" />
    <target xsi:type="File" name="debugLogFileTarget" fileName="${basedir}/Logs/nlogs/debugs/${shortdate}.log"
    layout="${longdate} ${logger} ${uppercase:${level}} ${message}" />
    <target xsi:type="File" name="warnLogFileTarget" fileName="${basedir}/Logs/nlogs/warns/${shortdate}.log"
    layout="${longdate} ${logger} ${uppercase:${level}} ${message}" />
    <target xsi:type="File" name="fatalLogFileTarget" fileName="${basedir}/Logs/nlogs/fatals/${shortdate}.log"
    layout="${longdate} ${logger} ${uppercase:${level}} ${message}" />
    <target xsi:type="File" name="traceLogFileTarget" fileName="${basedir}/Logs/nlogs/traces/${shortdate}.log"
    layout="${longdate} ${logger} ${uppercase:${level}} ${message}" />


        <target xsi:type="Exceptionless" name="exceptionless" apiKey="修改apiKey"
    serverUrl="修改serverUrl">
          <field name="host" layout="${machinename}" />
          <field name="identity" layout="${identity}" />
          <field name="windows-identity" layout="${windows-identity:userName=True:domain=False}" />
          <field name="process" layout="${processname}" />
    <!--堆栈信息-->
    <field name="StackTrace" layout="${stacktrace}"/>
    <!--Message信息-->
    <field name="Message" layout="${message}"/>
    <field name="LogLevel" layout="${level}"/>
    <field name="CreateDate" layout="${date}"/>
    <!--物理名称-->
    <field name="MachineName" layout="${machinename}" />
    <!--线程ID-->
    <field name="ThreadId" layout="${threadid}"/>
    <!--发生源-->
    <field name="CallSite" layout="${callsite}"/>
    <field name="AppdomainVersion" layout="${assembly-version}"/>
    <field name="Appdomain" layout="${appdomain}"/> 
    </target>  
    </targets>
    <rules>
    <logger name="*" minlevel="Trace" maxlevel="Fatal" writeTo="exceptionless" />
    <logger name="*" minlevel="Debug" maxlevel="Debug" writeTo="debugLogFileTarget" />
    <logger name="*" minlevel="Info" maxlevel="Info" writeTo="infoLogFileTarget" />
    <logger name="*" minlevel="Warn" maxlevel="Warn" writeTo="warnLogFileTarget" />
    <logger name="*" minlevel="Error" maxlevel="Error" writeTo="errorLogFileTarget" />
    <logger name="*" minlevel="Fatal" maxlevel="Fatal" writeTo="fatalLogFileTarget" />
    <logger name="*" minlevel="Trace" maxlevel="Trace" writeTo="traceLogFileTarget" />
    </rules>
    </nlog>

    配置文件结束

  • 相关阅读:
    子网划分
    数据报分片
    CRC校验
    内部网关协议RIP与OSPF的特点、区别
    简述协议与服务的区别、关系
    算法思想
    上机实验题7--求解装载问题
    上机实验题6--求最长单调递增子序列
    python进程和线程
    python序列化操作
  • 原文地址:https://www.cnblogs.com/jeffhong99/p/14929649.html
Copyright © 2020-2023  润新知