LogstashEncoder utf-8 not working

1.1k views Asked by At

when I use net.logstash.logback.encoder.LogstashEncoder output chinese words to log file, they always change to unicode char, like \u5FAE\u670D\u52A1\u51FA\u9519\uFF0C\u8BF7,
I've tried config charset=utf-8 whin LogstashEncoder, but it's not working,
Could someone tell me what can i do? thank you!
my logback.xml:

<appender name="stash" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
      <level>info</level>
    </filter>
    <file>${catalina.home}/logs/sublogs/development.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
      <fileNamePattern>${catalina.home}/logs/sublogs/development.log.%d{yyyy-MM-dd}</fileNamePattern>
      <maxHistory>30</maxHistory>
    </rollingPolicy>
    <encoder class="net.logstash.logback.encoder.LogstashEncoder">
          <charset>UTF-8</charset>    
    </encoder>
</appender>
1

There are 1 answers

0
Dmitry Ognyannikov On

Use charset="UTF-8" as argument. It works for me:

<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder"/>