logback on a mac returns question marks instead of words

后端 未结 2 1597
闹比i
闹比i 2021-02-09 02:23

I\'m just start using logback for logging my Java project running on glassfish3 AS, and I\'m noticing some strange thing. This string of code

LOG.error(\"Вычисле         


        
相关标签:
2条回答
  • 2021-02-09 03:03

    Try to define charset for encoder:

    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
        <file>../logs/logback.log</file>
        <encoder>
            <charset>utf-8</charset>
            <pattern>%d{HH:mm:ss.SSS} %-5level %logger{35} - %msg%n</pattern>
        </encoder>
    </appender>
    

    Sadly it's not described in documentation, but you can always lookup properties in source code. Specyfing <encoder> instantize PatternLayoutEncoder. Going up to its parent LayoutWrappingEncoder you can find method setCharset(). When specified it is used, as you can see in http://logback.qos.ch/xref/ch/qos/logback/core/encoder/LayoutWrappingEncoder.html#120

    0 讨论(0)
  • 2021-02-09 03:20

    You need to check if the used text editor is supporting your character set. Also the used terminal may affect the displayed characters also.

    I suggest using more or less UNIX commands from Terminal application, that should support your charset, to validate if the characters are printed ok.

    0 讨论(0)
提交回复
热议问题