scala - Play Framework: Logging time -
i've been using play framework many things, haven't come across in defining logging templates add timestamp log. services handle many requests/akka messages per minute, renders logging useless. example, use play logger bit this;
logger.error("could not fulfil request", someexception)
which how documentation goes. documentation specify, possible define own logging headers like;
val exceptionlogger = logger("exception") // , exceptionlogger.error("while handling some/request", someexception)
the log entries resulting above don't contain timestamp of sort;
[error] exception - while handling some/request ...
there's no mention of time whatsoever. now, workaround (not prettiest) like;
def exceptionlogger = { val dt = new datetime logger(s"$dt exception") }
which job, i'm not convinced. there better way format play's default logging behaviour?
play uses logback, can configure log format in conf/logback.xml
.
the logs in log/application.log
have date stamp default stdout not. add %date
pattern in stdout appender.
<appender name="stdout" class="ch.qos.logback.core.consoleappender"> <encoder> <pattern>%date %coloredlevel %logger{15} - %message%n%xexception{10}</pattern> </encoder> </appender>
Comments
Post a Comment