我刚刚开始使用Azure,我正在使用NLog来登录Azure Blob存储。我终于能够让它工作了,但现在我看到日志文件将时间戳设置为UTC。有没有方法可以格式化我的配置文件,将时间戳转换为美国中部时区?
<?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="C:\temp\fallback-log.txt"
throwConfigExceptions="true">
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
<add assembly="NLog.Extensions.AzureBlobStorage" />
</extensions>
<targets async="true">
<target
xsi:type="AzureBlobStorage"
name="azure"
layout="${longdate:universalTime=true} ${level:uppercase=true} - ${logger}: ${message} ${exception:format=tostring}"
connectionString="your-connection-string-goes-here"
container="logs"
blobName="${date:universalTime=true:format=yyyy-MM-dd}.log" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="azure" />
</rules>
</nlog>发布于 2021-02-03 21:59:39
很可能默认是Container UTC的本地时间;)
因此,更改容器中的时区确实是一种好方法。
如果您确实不喜欢这样做,您可以创建自定义布局渲染器:
在配置${date_cst}中使用
https://stackoverflow.com/questions/65939875
复制相似问题