1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/stoneson-web-service-test

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
nlog.config 7 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
Stoneson Отправлено 08.03.2021 04:06 4c8e9c0
<?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="nlog-internal.log">
<extensions>
<add assembly="NLog.Targets.ElasticSearch"/>
</extensions>
<!-- optional, add some variables
https://github.com/nlog/nlog/wiki/configuration-file#variables
-->
<!--
<variable name="myvar" value="myvalue"/>
-->
<variable name="fileformat"
value="${date} level:${level} processname:${processname} machinename:${machinename}
${newline}message:${message}
${newline}-----------------------------------------------------------------------------------" />
<!--
see https://github.com/nlog/nlog/wiki/configuration-file
for information on customizing logging rules and outputs.
-->
<targets>
<!--
add your targets here
see https://github.com/nlog/nlog/wiki/targets for possible targets.
see https://github.com/nlog/nlog/wiki/layout-renderers for the possible layout renderers.
-->
<!--
write events to a file with the date in the filename.
<target xsi:type="file" name="f" filename="${basedir}/logs/${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}" />
-->
<target name="file" xsi:type="file"
filename="${basedir}/log/${date:format=yyyy-MM}/${shortdate}.log"
layout="${fileformat}"
maxarchivefiles="5"
archiveabovesize="1024000"
archiveevery="day"/>
<!--添加一个新条目让日志输出到控制台中,并添加必要的输出布局(layout)-->
<target name="console" xsi:type="Console" layout="${longdate}|${level}|${message}"/>
<!--说明 xsi:type="Console"指定输出到控制台;layout指定输出文件内容的样式 ${longdate}是日期(具体到毫秒),${level}是日志的等级;${message}是具体要输出的内容。-->
<target name="coloredConsole" xsi:type="ColoredConsole" useDefaultRowHighlightingRules="false"
layout="${time}|${pad:padding=5:inner=${level:uppercase=true}}|${message}${newline}-----------------------------------------------------------------------------------" >
<highlight-row condition="level == LogLevel.Debug" foregroundColor="DarkGray" />
<highlight-row condition="level == LogLevel.Info" foregroundColor="Gray" />
<highlight-row condition="level == LogLevel.Warn" foregroundColor="Yellow" />
<highlight-row condition="level == LogLevel.Error" foregroundColor="Red" />
<highlight-row condition="level == LogLevel.Trace" foregroundColor="Green" />
<highlight-row condition="level == LogLevel.Fatal" foregroundColor="Blue" backgroundColor="black" />
</target>
<target name="ElasticSearchWeb" xsi:type="ElasticSearch"
uri="${configsetting:name=ESuri}"
index="webapi_nlog_${date:format=yyyyMM}"
documentType="doc"
includeAllProperties="true">
<!--<field name="apiName" layout="${event-context:item=apiName}" />
<field name="apiTitle" layout="${event-context:item=apiTitle}" />
<field name="message" layout="${event-context:item=logMessage}" />-->
<field name="MachineName" layout="${machinename}" />
<!--<field name="LogLevel" layout="${level}" />
<field name="LogTime" layout="${event-context:item=logtime}" />-->
<!--<field name="origin" layout="${callsite}" />-->
<field name="message" layout="${message}" />
<field name="stackTrace" layout="${stacktrace}" />
<field name="shortdate" layout="${shortdate}"/>
<!--<field name ="windows-identity" layout="${windows-identity}"/>
<field name ="Request" layout="${aspnet-Request}"/>-->
<!--<field name ="aspnet-Application" layout="${aspnet-Application}"/>-->
<field name ="QueryString" layout="${aspnet-Request-QueryString}"/>
<field name ="UserAgent" layout="${aspnet-Request-UserAgent}"/>
<!--<field name ="aspnet-Session" layout="${aspnet-Session}"/>
<field name="aspnet-Request-Url" layout="${aspnet-Request-Url}"/>
<field name="aspnet-Request-IP" layout="${aspnet-Request-IP}"/>-->
<field name="Host" layout="${aspnet-Request-Host}"/>
<field name="Method" layout="${aspnet-Request-Method}"/>
<!--<field name="iis-site-name" layout="${iis-site-name}"/>-->
<!--<field name="Properties" layout="
${machinename}
${longdate}
${level:uppercase=true}
${logger}
${message}
${exception}|${processid}|${stacktrace}|${threadname}" />-->
</target>
<target name="ElasticSearch2" xsi:type="BufferingWrapper" flushTimeout="5000">
<target xsi:type="ElasticSearch"/>
</target>
<target name="ElasticSearch11" xsi:type="ElasticSearch" ConnectionStringName="ElasticsearchUrl" index="WebApi-Nlog-${date:format=yyyy.MM.dd}" documentType="logevent" includeAllProperties="true"
layout="[${date:format=yyyy-MM-dd HH\:mm\:ss}][${level}] ${logger} ${message} ${exception:format=toString}">
<field name="MachineName" layout="${machinename}" />
<!--<field name="AllEventProperties" layout="${all-event-properties:format=[key]=[value]:separator=;:includeCallerInformation=true}" />-->
<field name="Time" layout="${longdate}" />
<field name="level" layout="${level:uppercase=true}" />
<field name="logger" layout=" ${logger}" />
<field name="message" layout=" ${message}" />
<field name="exception" layout=" ${exception:format=toString}" />
<field name="processid" layout=" ${processid}" />
<field name="threadname" layout=" ${threadname}" />
<field name="stacktrace" layout=" ${stacktrace}" />
<field name="Properties" layout="${machinename} ${longdate} ${level:uppercase=true} ${logger} ${message} ${exception}|${processid}|${stacktrace}|${threadname}" />
</target>
</targets>
<rules>
<!-- add your logging rules here -->
<!--
write all events with minimal level of debug (so debug, info, warn, error and fatal, but not trace) to "f"
<logger name="*" minlevel="debug" writeto="f" />
-->
<!--
level example
fatal highest level: important stuff down
error for example application crashes / exceptions.
warn incorrect behavior but the application can continue
info normal behavior like mail sent, user updated profile etc.
debug executed queries, user authenticated, session expired
trace begin method x, end method x etc
-->
<!--
logging 水平分为以下等级“trace<<debug<<info<<warn<<error<<fatal ”,如果我们选择info值,则tracedebug等级的信息不会被输出。
<logger name="*" minlevel="trace" writeto="file"/>-->
<logger name="*" minlevel="trace" writeto="coloredConsole"/>
<logger name="*" level="error" writeTo="ElasticSearchWeb"/>
<logger name="*" level="fatal" writeTo="ElasticSearchWeb"/>
</rules>
</nlog>

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/stoneson-web-service-test.git
git@api.gitlife.ru:oschina-mirror/stoneson-web-service-test.git
oschina-mirror
stoneson-web-service-test
stoneson-web-service-test
master