简体   繁体   English

如何在 C# 中按小时创建 NLog 配置 Timeshift?

[英]How can I create a NLog Config Timeshift by hours in C#?

How can I, if possible, create a log file with a timestamp that is shifted by x hours?如果可能,我如何创建一个时间戳偏移 x 小时的日志文件?

<variable name="logdt" value="${shortdate}"/>
<targets>
    <target
        name="file" xsi:type="File"
        layout="${shortdate}${semi}${time}${semi}${message}"
        fileName="${basedir}\logs\${logdt}**-6h**.csv" 
        archiveFileName="${basedir}\archives\${logdt}**-6h**.{#}.zip"
        archiveEvery="Day"
        archiveNumbering="Rolling"
        maxArchiveFiles="7"
        enableArchiveFileCompression="true"
        keepFileOpen="true"
        openFileCacheTimeout="30"
    />
</targets>

You can configure the Time Source.您可以配置时间源。

https://github.com/NLog/NLog/wiki/Time-Source https://github.com/NLog/NLog/wiki/Time-Source

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM