0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

C#(.NET)のNLogでshift_jis形式で出力する方法

Last updated at Posted at 2024-09-04

はじめに

.Net FrameworkではNLogでの出力ファイルがshift-jis形式だった。
.NETで同じNLog.configファイルを使ってもUTF-8形式に変わってしまった。

解決方法

NLogの問題ではなく、.NETの問題だった。
shift_jisなどのマイナーエンコードは明示的に読み込まないといけなくなったらしい。
下記2か所に対応することでshift_jis出力されるようになった。

Program.cs
//Encodingを明示的に読み込む。
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
NLog.confg
//"shift_jis"指定する
<target name="name01" xsi:type="File" encoding="shift_jis" ...>

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?