What is the default local encoding for LayoutWrappingEncoder?

The Logback 1.1.3 documentation does LayoutWrappingEncodernot indicate what the default encoding will be if the user did not install it, but the source code says:

By default, this property is null, which corresponds to the default encoding of the system.

However, I use PatternLayoutEncoder(c RollingFileAppender) and seem to output files to UTF-8 (and the default character set for my Windows 7 Professional system is probably not UTF-8).

The UTF-8 output is actually what I want, but I want to make sure that I don't get it by accident, as the documentation seems to point to something else. So why does Logback give me UTF-8 output if I did not explicitly specify the encoding?

+4
source share
2 answers

Callback character encoding

You can use <charset>in your definition PatternLayoutEncoder, since this is a subclass LayoutWrappingEncoderthat the method provides setCharset. This is indicated in the class excerpt documentation, but no xml configuration is specified. For LayoutWrappingEncoder the answer was given here: [Logback-user]: how to use UTF-8 .

So, if you configure the code, you can call the method setCharsetusing UTF-8. Or, if you are configuring through xml, this is:

<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
        <charset>UTF-8</charset>            
        <outputPatternAsHeader>true</outputPatternAsHeader>
        <pattern>[%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>

Default File Encoding

, , . UTF-8 (, my windows-1252). , , logback UTF-8, . logback UTF-8 -, file.encoding - , , .

, Sun file.encoding, Oracle VM:

"file.encoding" J2SE; Sun . ; .

Eclipse Maven

maven eclipse UTF-8 / Run Configuration ( ), eclipse JVM UTF-8, file.encoding. : Eclipse

+6

Java file.encoding, JVM ( ). Eclipse, Netbeans, Maven .. UTF-8, , , UTF-8, .

, , . , convertToBytes ( ).

Unix file.encoding (, LANG=en_US.UTF-8, , ).
Windows chcp. , . , 65001 UTF-8. systeminfo | findstr Locale.

: , - . .

0

All Articles