Log4Net:以2字节语言(日语,中文等)登录 [英] Log4Net: Logging in 2 byte languages (japanese, chinese etc.)

查看:58
本文介绍了Log4Net:以2字节语言(日语,中文等)登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用log4net以2字节语言(中文,日文等)将数据记录到文件中.

I would like to log data to a file in 2 byte languages (chinese, japanese etc) using log4net.

如何正确配置log4net来做到这一点?

How to properly configure log4net to do that?

推荐答案

日志文件编码由

The log file encoding is specified by FileAppender.Encoding. It can be configured using the encoding configuration element. Example:

<appender name="FileAppender" type="log4net.Appender.FileAppender">
    <file value="file.log" />
    <encoding value="utf-8" />
    ...

该值为代码页名称.使用 System.Text.Encoding.GetEncoding(string) 方法可获得相应的编码.有关代码页的列表,请参见Encoding类文档.

The value is the code page name. The corresponding Encoding is obtained using the System.Text.Encoding.GetEncoding(string) method. For a list of code pages, see the Encoding class documentation.

这篇关于Log4Net:以2字节语言(日语,中文等)登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆