skip to Main Content

I run Spring Boot application and have following logback-spring.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <property name="LOGS" value="./logs" />

    <appender name="Console"
              class="ch.qos.logback.core.ConsoleAppender">
        <layout class="ch.qos.logback.classic.PatternLayout">
            <Pattern>
                %black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%C{1.}): %msg%n%throwable
            </Pattern>
        </layout>
    </appender>

    <appender name="RollingFile"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOGS}/logger.log</file>
        <encoder
                class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <charset>UTF-8</charset>
            <Pattern>%d %p %C{1.} [%t] %m%n</Pattern>
        </encoder>

        <rollingPolicy
                class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!-- rollover daily and when the file reaches 10 MegaBytes -->
            <fileNamePattern>${LOGS}/archived/logger-%d{yyyy-MM-dd}.%i.log
            </fileNamePattern>
            <timeBasedFileNamingAndTriggeringPolicy
                    class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>10MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
        </rollingPolicy>
    </appender>

    <!-- LOG everything at INFO level -->
    <root level="info">
        <appender-ref ref="RollingFile" />
        <appender-ref ref="Console" />
    </root>
</configuration>

Default Spring Boot logs works fine:

2020-07-06 10:24:02,276 INFO  [restartedMain] org.springframework.boot.SpringApplication: No active profile set, falling back to default profiles: default

But when app tries to log incoming information, I’ll get:

2020-07-06 10:24:24,604 INFO  [Áèáëèîòåêà èãð Google Play Telegram Executor] ru.miroha.bot.GooglePlayGameBot: Hello, Test!

Same in the console and a file.

Google Play Telegram Executor is legit, but what is Áèáëèîòåêà èãð it?

If I’ll remove this logback.xml configuration and run with default Spring Bot logger this message will look like:

2020-07-06 10:22:00.418  INFO 6796 --- [legram Executor] ru.miroha.bot.GooglePlayGameBot          : Hello!

What’s wrong?

2

Answers


  1. Chosen as BEST ANSWER

    I found the real problem. This thread name contains my telegram bot name (api features I guess), and this api cannot correctly process the cyrillic alphabet.


  2. The encoded text is coming from %C{1.} in your config. Maybe the caller of your object has classnames intentionally obfuscated? Is the class invoking that row from a library?

    Do you need that depth of caller loging?caller that you want to be logging as opposed to %C{0}?

    More on caller logging:
    http://logback.qos.ch/manual/layouts.html

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search