How logback overrides (removes) the appender-ref configuration in root.

you want the general log to be recorded on both the screen and the file log.log, and the output level is INFO.

<root level="INFO">
    <appender-ref ref="CONSOLE" />
    <appender-ref ref="FILE" />
</root>

but mybatis"s sql query log requires special processing. It is only output to a special file, mybatis.log, and the output level is DEBUG

.

this is what it says so far:

<appender name="mybatis" class="ch.qos.logback.core.FileAppender">
    <file>logs/mybatis.log</file>
    <encoder>
        <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</pattern>
    </encoder>
</appender>

<logger name="org.sang.mapper" level="DEBUG">
    <appender-ref ref="mybatis" />
</logger>

in this case, the screen, log.log, and mybatis.log all have sql query log output with mybatis.

     
<logger name="org.sang.mapper" level="DEBUG"> 

<logger name="org.sang.mapper" level="INFO">

then there is no sql query log output for mybatis on the screen, log.log, or mybatis.log.

I would like to ask how to configure to achieve my initial requirements:
the general log is recorded on both the screen and the file log.log, and the output level is INFO.
but mybatis"s sql query log is specially handled. It is only output to a special file, mybatis.log, and the output level is DEBUG

.
Mar.05,2021

<logger name="org.sang.mapper" level="DEBUG" additivity="false">
    <appender-ref ref="mybatis" />
</logger>
<root level="INFO">
    <appender-ref ref="CONFOLE" />
    <appender-ref ref="FILE" />
    ...
</root>
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea36c2-47a29.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea36c2-47a29.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?