Fra*_*hop 1 logging timezone nlog elasticsearch
我用于记录Microsoft.Extensions.Logging 和 NLog。日志写入Elasticsearch。当我使用Kibana查找日志时,所有日志都是在 UT 写入的,这意味着与我的本地时间(时区)MET 相差两个小时。我想查看我的日志以及 Kibana 当地时间。如何调整日志记录的时区?
我添加 NLog.config:
<nlog autoReload="true" throwExceptions="false"
internalLogLevel="Info" internalLogFile="NLogError.log"
xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="Logfile" xsi:type="File"
fileName="${basedir}dap.log"
layout="${longdate} ${level} ${callsite} -> ${message} ${exception:format=Message,StackTrace}"
archiveFileName="${basedir}/archives/log.{#}.log"
archiveEvery="Day"
archiveNumbering="Rolling"
maxArchiveFiles="14"
keepFileOpen="false"
/>
<target xsi:type="Network"
name="CentralLog"
newLine ="false"
maxMessageSize="65000"
connectionCacheSize="5"
encoding="utf-8"
keepConnection="false"
maxQueueSize="100"
address="tcp://myurl.org:5544"
onOverflow="Split">
<layout type="JsonLayout">
<attribute name="machinename" layout="${machinename}" />
<attribute name="level" layout="${level:upperCase=true}" />
<attribute name="processname" layout="${processname}" />
<attribute name="processid" layout="${processid}" />
<attribute name="sendertimestamp" layout="${date:universalTime=true:format=yyyy-MM-ddTHH\:mm\:ss.fff}" />
<attribute name="module" layout="dhp DataPickerApi ${logger}" />
<attribute name="message" layout="${message}" />
<attribute name="exception" layout="${exception}" />
<attribute name="activityId" layout="${activityId}" />
</layout>
</target>
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="Logfile" />
<logger name="*" minlevel="Trace" writeTo="CentralLog"/>
</rules>
</nlog>
Run Code Online (Sandbox Code Playgroud)
不使用universalTime=true
?所以代替这个:
<attribute name="sendertimestamp"
layout="${date:universalTime=true:format=yyyy-MM-ddTHH\:mm\:ss.fff}" />
Run Code Online (Sandbox Code Playgroud)
用这个:
<attribute name="sendertimestamp"
layout="${date:format=yyyy-MM-ddTHH\:mm\:ss.fff}" />
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3358 次 |
最近记录: |