5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

NLOGのアーカイブ機能を日付ファイル名で

Last updated at Posted at 2018-12-12

いつも忘れがちなのでメモ。
NLOGのアーカイブ機能と、ファイル名の{shotdate}は併用できない。
ファイル名は固定、アーカイブのファイル名を日付は可能。archiveNumbering="Date"、archiveFileNameの日付部分は{#}を使う。

The problem is the {shortdate} in fileName=
{shortdate} means it rolls automatically, so the archive/compression-logic gets confused.

ex.

nlog.config
  <targets>
    <target
      xsi:type="File"
      name="TraceLog"
      fileName="${basedir}/logs/trace.log"
      encoding="UTF-8"
      lineEnding="CRLF"
      archiveFileName="${basedir}/logs/trace_{#}.log.zip"
      archiveEvery="Day"
      archiveNumbering="Date"
      enableArchiveFileCompression="true"
      layout="${longdate} [${threadid:padding=8}] [${uppercase:${level:padding=-5}}] ${message} ${exception:format=Message, Type, ToString:separator=\r\n}" />
  </targets>

ex.
以下のサイトでは、NLOGのアーカイブ機能と、ファイル名の{shotdate}は併用してるが、これだと正常にアーカイブできなかった」。
https://www.niceonecode.com/Blog/49/Archive-nlog-files-and-enable-Archive-File-Compression-Compress-the-archive-files-into-the-zip-files-

ex.
細かい仕様は以下参照
https://github.com/nlog/NLog/wiki/File-target

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?