hello,

I have a spring application that logs to a primary log file
("caseportal.log"):

(note: I replaced the real root package of my code by "root.package")

    <!--Daily rolling file appender -->
    <appender name="file" 
class="ch.qos.logback.core.rolling.RollingFileAppender">
        <File>${catalina.base}/logs/caseportal.log</File>
        <rollingPolicy 
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            
<FileNamePattern>${catalina.base}/logs/caseportal-%d.log.zip</FileNamePattern>
            <maxHistory>120</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>${logPattern}</pattern>
        </encoder>
    </appender>

plus *additionally*, for some packages, to several other log files
(picked one example, "cp-deletion.log", here):

    <appender name="deletion" 
class="ch.qos.logback.core.rolling.RollingFileAppender">
        <File>${catalina.base}/logs/cp-deletion.log</File>
        <rollingPolicy 
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            
<FileNamePattern>${catalina.base}/logs/cp-deletion-%d.log.zip</FileNamePattern>
            <maxHistory>120</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>${logPattern}</pattern>
        </encoder>
    </appender>

    [...]

    <logger name="root.package.core.service.deletion" level="DEBUG">
        <appender-ref ref="deletion"/>
    </logger>
    <logger name="root.package.core.domain.deletion" level="DEBUG">
        <appender-ref ref="deletion"/>
    </logger>
    <logger name="root.package.core.scheduledtasks.BulkDeletionCron" 
level="DEBUG">
        <appender-ref ref="deletion"/>
    </logger>
    <logger name="root.package.frontend.runners.BulkDeletionRunner" 
level="DEBUG">
        <appender-ref ref="deletion"/>
    </logger>

Now I would like some packages to *only* log to another log file
("cp-retentionperiodad.log").
I am trying to achieve this by logging with loglevel TRACE, configuring
the root logger to log only DEBUG for those packages:

    <logger name="root.package" level="DEBUG"/>

and configuring the other log file with loglevel TRACE for those
packages:

    <appender name="retentionperiodad" 
class="ch.qos.logback.core.rolling.RollingFileAppender">
        <File>${catalina.base}/logs/cp-retentionperiodad.log</File>
        <rollingPolicy 
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            
<FileNamePattern>${catalina.base}/logs/cp-retentionperiodad-%d.log.zip</FileNamePattern>
            <maxHistory>120</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>${logPattern}</pattern>
        </encoder>
    </appender>
    
    <logger name="root.package.core.scheduledtasks.RetentionPeriodAdCron" 
level="TRACE">
        <appender-ref ref="retentionperiodad"/>
    </logger>
    <logger name="root.package.core.ad.authorize.ActiveDirectoryClient" 
level="TRACE">
        <appender-ref ref="retentionperiodad"/>
    </logger>

But the "root logger" (?) caseportal.log still logs these TRACE
messages, so they appear there (and in cp-retentionperiodad.log).

Is there a better way to log some packages *only* to another log?
If not, how can I get this to work?

The complete logback.xml is attached.

Many Thanks and Merry Christmas for those who celebrate this!
-- 
Felix Natter

Attachment: logback.xml
Description: XML document

_______________________________________________
logback-user mailing list
[email protected]
http://mailman.qos.ch/mailman/listinfo/logback-user

Reply via email to