Is it safe to disable "play" logger?

已查看 53 次
跳至第一个未读帖子

Aleksandar Stojadinovic

未读,
2016年2月4日 11:40:512016/2/4
收件人 play-framework
Hello,

Is it considered safe to disable the play logger (<logger name="play" level="OFF"/>), in production? The thing is I have a feeling there is a kind of duplication, since the PlayDefaultUpstreamHandler logs everything as an error, even though I handle some things in a custom ErrorHandler and log it a INFO or WARN or ignor eit. I can disable this by just disabling the play logger and it does not show up anymore. After all, server errors not handled by me are generally sent up to the DefaultHttpErrorHandler, which logs them as error by default, also. My fear is, will I miss some important messages from this logger?

Best regards

René Grüner Vangsgaard

未读,
2016年2月9日 02:24:282016/2/9
收件人 play-framework
Hi

I am also annoyed that errors handled in a custom ErrorHandler are logged. I hacked around it by overriding onServerError(), here is a snippet of my code:
  override def onServerError(request: RequestHeader, exception: Throwable): Future[Result] = {
   
try {
      val usefulException
= HttpErrorHandlerExceptions.throwableToUsefulException(sourceMapper.sourceMapper,
        environment
.mode == Mode.Prod, exception)

      onServerErrorCommon
(request, usefulException).getOrElse{
       
// If we haven't handled the exception ourselves, use default error handling.
        logServerError
(request, usefulException)

        environment
.mode match {
         
case Mode.Prod => super.onProdServerError(request, usefulException)
         
case _ => super.onDevServerError(request, usefulException)
       
}
     
}
   
} catch {
     
case NonFatal(e) =>
       
Logger.error("Error while handling error", e)
       
Future.successful(InternalServerError)
   
}
 
}

 
def onServerErrorCommon(request: RequestHeader, exception: UsefulException): Option[Future[Result]] = {
   
...
 
}

It is almost a copy of the default onServerError() with the logging removed for errors that I have handled.

Regards,
René
回复全部
回复作者
转发
0 个新帖子