From f482cf82edb22a8d1b234c208004529318dfcfbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kleinbo=CC=88lting?= Date: Wed, 2 Nov 2022 14:00:36 +0100 Subject: [PATCH 1/2] fix: Allow warn logging for requests which are failures, ensure debug logging level for all other requests (DEV-1255) --- 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..a7a49c9464 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} " + s"${ctx.request.uri} took: ${took}ms" + if (resp.status.isFailure()) metricsLogger.warn(message) else metricsLogger.debug(message) resp } } From 4f59ea27dc9bb37684c181997c10f9395100e2b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kleinb=C3=B6lting?= Date: Wed, 2 Nov 2022 14:31:59 +0100 Subject: [PATCH 2/2] join strings Co-authored-by: Balduin Landolt <33053745+BalduinLandolt@users.noreply.github.com> --- .../main/scala/org/knora/webapi/routing/AroundDirectives.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 a7a49c9464..af2e23e31f 100644 --- a/webapi/src/main/scala/org/knora/webapi/routing/AroundDirectives.scala +++ b/webapi/src/main/scala/org/knora/webapi/routing/AroundDirectives.scala @@ -22,7 +22,7 @@ trait AroundDirectives extends InstrumentationSupport { val start = System.currentTimeMillis() mapResponse { resp => val took = System.currentTimeMillis() - start - val message = s"[${resp.status.intValue()}] ${ctx.request.method.name} " + s"${ctx.request.uri} took: ${took}ms" + 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 }