简体   繁体   中英

LogstashEncoder utf-8 not working

when I use net.logstash.logback.encoder.LogstashEncoder output chinese words to log file, they always change to unicode char, like \微\服\务\出\错\,\请 ,
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>

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM