How to output different business logs separately by logback

use logback to output logs. You want to output logs from different businesses to different files.

now there is a package com.manage.ddd. The business under this package is special and wants to be displayed separately from the logs of other modules.
but in actual development, the classes under com.manage.ddd call a large number of utility classes in other packages (all modules are called together). Can the logs in the tool classes be output to file a when called by classes under com.manage.ddd? Output to file b when classes in other packages are called

is now configured as follows:

  <!---->
<appender name="xjkUserAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <fileNamePattern>${log.path}/testLog222.%d{yyyy-MM-dd}.log</fileNamePattern>
        <maxHistory>12</maxHistory>
    </rollingPolicy>
    <encoder charset="UTF-8">
        <Pattern>${log.content}</Pattern>
    </encoder>
</appender>

  <logger name="com.controller.business.ElkLogsController" level="INFO" additivity="false">
    <appender-ref ref="xjkUserAppender"/>
   <!-- <appender-ref ref="xjkUserAppender"/>-->
</logger>

the above configuration can output the logs in ElkLogsController separately, but for the logs in the called tool class, it cannot be output separately

May.04,2021
Menu