0
votes

we are using logback for our logging and we have following jars in our class path

jcl-over-slf4j-1.7.7.jar logback-classic-1.1.3.jar logback-core-1.1.3.jar slf4j-api-1.7.7.jar janino-2.7.8.jar

In each app, i have minimal config in logback.xml. Like this

 <configuration scan="true" scanPeriod="10 seconds">
   <statusListener
      class="ch.qos.logback.core.status.OnConsoleStatusListener" />
   <contextName>myapp- ${HOSTNAME}</contextName>
   <include file="${logback.path}/logback.xml"/>
</configuration>

Then in my file system, I have config like this

<included>
<property name="LOG_HOME" value="C:\\tmp" />
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
    <layout class="ch.qos.logback.classic.PatternLayout">
        <Pattern>%d{yyyy-MM-dd-HH:mm:ss.SSS} cn=%contextName [%thread] %-5level %logger{36} - %msg%n</Pattern>
    </layout>
</appender>

<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <fileNamePattern>${LOG_HOME}/application.%d{yyyy-MM-dd-HH-mm}_%i.zip</fileNamePattern>
        <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
            <maxFileSize>250KB</maxFileSize>
        </timeBasedFileNamingAndTriggeringPolicy>
    </rollingPolicy>

    <encoder>
        <pattern>%d{yyyy-MM-dd-HH:mm:ss.SSS} cn=%contextName [%thread] %-5level %logger{36} - %msg%n</pattern>
    </encoder>
</appender>

<logger name="org.springframework" level="INFO"/>
<logger name="com" level="INFO"/>

<root level="INFO">
    <appender-ref ref="stdout"/>
    <appender-ref ref="file" />
</root>

Now when i deploy my app, i do see logs from spring framework in application.xxx.log file but my actual application code which logs some statement are not showing up in this log file

In my code, i m using slf4j logger factory to get the logger and then just log some dummy statements, like this

private static final Logger logger = LoggerFactory.getLogger(GameService.class);
logger.info("Playing cricket game.......");
1

1 Answers

0
votes

I think i figured out the issue. Some where in our lib, we were using common logger util class which was modifying logger context object. As soon as i removed that dependency , things worked out fine. Since that was the old way of logging , we no longer needed common logger util.