There are other questions about configuring programmatically log4j2, but I coun't find a way to configure the log output encoding?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
I didn't solve it programatically. My solution was to execute the java interpreter with this option:
java -Dfile.encoding=utf-8
回答2:
In log4j one would do the following, so I assume too for log4j2:
Logger hlogger = Logger.getLogger("org.hibernate.stat");
SimpleLayout layout = new SimpleLayout();
ConsoleAppender consoleAppender = new ConsoleAppender(layout);
consoleAppender.setEncoding("UTF-8");
hlogger.addAppender(consoleAppender);
hlogger.setLevel(Level.DEBUG);