From 92531ceb0c38f0c6117bc08633bb66a89dbcabc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kleinb=C3=B6lting?= Date: Thu, 3 Nov 2022 09:23:39 +0100 Subject: [PATCH] fix: Allow warn logging for requests/responses which are failures (#2273) Ensure debug logging level for all other requests DEV-1255 Co-authored-by: Balduin Landolt <33053745+BalduinLandolt@users.noreply.github.com> --- webapi/src/main/resources/logback.xml | 1 + .../scala/org/knora/webapi/routing/AroundDirectives.scala | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/webapi/src/main/resources/logback.xml b/webapi/src/main/resources/logback.xml index a2b4b9b983..ed89b33aa0 100644 --- a/webapi/src/main/resources/logback.xml +++ b/webapi/src/main/resources/logback.xml @@ -38,6 +38,7 @@ + diff --git a/webapi/src/main/scala/org/knora/webapi/routing/AroundDirectives.scala b/webapi/src/main/scala/org/knora/webapi/routing/AroundDirectives.scala index 321557b9e2..af2e23e31f 100644 --- a/webapi/src/main/scala/org/knora/webapi/routing/AroundDirectives.scala +++ b/webapi/src/main/scala/org/knora/webapi/routing/AroundDirectives.scala @@ -21,10 +21,9 @@ trait AroundDirectives extends InstrumentationSupport { def logDuration: Directive0 = extractRequestContext.flatMap { ctx => val start = System.currentTimeMillis() mapResponse { resp => - val took = System.currentTimeMillis() - start - metricsLogger.info( - s"[${resp.status.intValue()}] ${ctx.request.method.name} " + s"${ctx.request.uri} took: ${took}ms" - ) + val took = System.currentTimeMillis() - start + val message = s"[${resp.status.intValue()}] ${ctx.request.method.name} ${ctx.request.uri} took: ${took}ms" + if (resp.status.isFailure()) metricsLogger.warn(message) else metricsLogger.debug(message) resp } }