[logback-user] How to use UTF-8?

Ceki Gülcü ceki at qos.ch
Thu May 5 20:44:01 CEST 2011


On 05/05/2011 6:24 PM, moxol wrote:
>
> I have tried to put some UTF-8 characters with File appender but I didn't
> succed. It only gives me question marks ?? instead of characters.
>
> How to use UTF-8?

Hello,

You can set the char encoding with the help of the "charset" property of 
the encoder referenced by your appender. Example:

<appender name="FILE" class="ch.qos.logback.core.FileAppender">
   <file>testFile.log</file>
   <append>true</append>

   <encoder>
     <charset>UTF-8</charset>
     <pattern>%-4r [%t] %-5level %logger{35} - %msg%n</pattern>
   </encoder>
</appender>

HTH,

-- 
QOS.ch, main sponsor of cal10n, logback and slf4j open source projects, 
is looking to hire talented software developers. For further details, 
see http://logback.qos.ch/job.html


More information about the Logback-user mailing list