I have a Play server (Play Framework 2.3) implemented in Java. I want to keep API call logs in files limiting the maximum number of files and the maximum size of each file. I have the following application-logger.xml file
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>/home/ajay/projects/application.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>application-log-%d{yyyy-MM-dd}.gz</fileNamePattern> <maxHistory>30</maxHistory> </rollingPolicy> <encoder> <pattern>%date{yyyy-MM-dd HH:mm:ss ZZZZ} - [%level] - from %logger in %thread %n%message%n%xException%n</pattern> </encoder> </appender> <appender name="ACCESS_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>/home/ajay/projects/access.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>access-log-%d{yyyy-MM-dd}.gz</fileNamePattern> <maxHistory>7</maxHistory> </rollingPolicy> <encoder> <pattern>%date{yyyy-MM-dd HH:mm:ss ZZZZ} %message%n</pattern> <immediateFlush>false</immediateFlush> </encoder> </appender> <logger name="access" level="INFO" additivity="false"> <appender-ref ref="ACCESS_FILE" /> </logger> <root level="INFO"> <appender-ref ref="FILE"/> </root>
which I took from here . I do not fully understand the above configuration . I use the following lines to enter the access.log file
import play.Logger; // log in the access.log file final Logger.ALogger accessLogger = Logger.of("access"); accessLogger.info("Logging api call from the client");
However, this will not work. The access.log file is empty, and all entries go to the application.log file. I commented on all the registrar settings in application.conf . When I looked at the Logger.class file, I found this line
private static final ALogger logger = of("application");
Is this the reason why it does not work? Please suggest how to fix this.
source share