zoukankan      html  css  js  c++  java
  • .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>

    配置文件结束

  • 相关阅读:
    timerfd与eventfd
    boost--asio
    boost--线程
    boost--线程同步
    C++11--lambda表达式
    Java数据类型中String、Integer、int相互间的转换
    Jsoup网页抓取
    线程池
    Java
    用cmd来向mysql导入sql文件
  • 原文地址:https://www.cnblogs.com/jeffhong99/p/14929649.html
Copyright © 2011-2022 走看看