I have formatted the logs generated by play using logger.xml
file in conf
folder to get the desired format. In my local environment when i am using the normal play commands like play ~run
or play -Dlogger.resource=logger.xml
start. But when i do packaging with play dist
and start the process with command sudo ./start -Dlogger.resource=logger.xml
it is printing default logs without any format.
logger.xml
<configuration>
<conversionRule conversionWord="coloredLevel" converterClass="play.api.Logger$ColoredLevel" />
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${application.home}/logs/application.log</file>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%level] %class:%method %msg%n </pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%level] %class:%method %msg%n </pattern>
</encoder>
</appender>
<root level="ERROR">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
<logger name="application" level="debug" additivity="false">
<appender-ref ref="STDOUT"/>
<appender-ref ref="FILE"/>
</logger>
</configuration>