You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by Adam Raszkiewicz <ar...@medallies.com> on 2019/05/15 15:44:49 UTC

Separate logs for James JPA Guice 3.2

I’m trying to separate logs for James JPA Guice 3.2. My goal is to have James core code to log to the default james.log and then code from mailets to log to james-app.log

James is starting as

java -classpath "james-server-jpa-guice.jar:james-server-jpa-guice.lib/*:james-server-jpa-guice.lib" -javaagent:james-server-jpa-guice.lib/openjpa-3.0.0.jar -Dlogback.configurationFile=./conf/logback.xml -Dworking.directory=. org.apache.james.JPAJamesServerMain >> ./logs/james.log 2>&1 &

then in the logback.xml I have

<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
            <resetJUL>true</resetJUL>
    </contextListener>

    <!--  Appenders for console and logs -->

    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
            <encoder>
                    <pattern>%d{HH:mm:ss.SSS} %highlight([%-5level]) %thread %logger{15}:%line - %msg%n%rEx</pattern>
                    <immediateFlush>false</immediateFlush>
            </encoder>
    </appender>

    <appender name="JAMES" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <file>./logs/james.log</file>
            <encoder>
                    <pattern>%d{HH:mm:ss.SSS} [%-5level] %thread %logger{15}:%line - %msg%n%rEx</pattern>
                    <immediateFlush>false</immediateFlush>
            </encoder>

            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
               <fileNamePattern>./logs/james.%d{yyyy-MM-dd}.log</fileNamePattern>
               <maxHistory>30</maxHistory>
            </rollingPolicy>
    </appender>

<appender name="JAMES-APP" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>./logs/james-app.log</file>
    <encoder>
        <pattern>%d{HH:mm:ss.SSS} [%-5level] %thread %logger{15}:%line - %msg%n%rEx</pattern>
        <immediateFlush>false</immediateFlush>
    </encoder>

    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <fileNamePattern>./logs/james-app.log.%d{yyyy-MM-dd}</fileNamePattern>
        <maxHistory>30</maxHistory>
    </rollingPolicy>
</appender>

    <logger name="org.domain.mypackage" level="DEBUG">
        <appender-ref ref="JAMES-APP" />
    </logger>

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

but nothing is getting logged to the james-app.log

At that state I’m not sure if I can do that kind of logging configuration for the James.

Adam Raszkiewicz
Front End Web Developer
MedAllies, Inc.
300 Westage Business Center Drive, Suite 320
Fishkill, NY 12524
Office:  845.896.0191
Fax:  845.896.9306
www.medallies.com<http://www.medallies.com>
[Twitter-Bird]<https://twitter.com/medallies>Follow us on Twitter @MedAllies<https://twitter.com/medallies>