Skip to content

Commit

Permalink
fix: Allow warn logging for requests/responses which are failures (#2273
Browse files Browse the repository at this point in the history
)

Ensure debug logging level for all other requests

DEV-1255

Co-authored-by: Balduin Landolt <33053745+BalduinLandolt@users.noreply.github.com>
  • Loading branch information
seakayone and BalduinLandolt committed Nov 3, 2022
1 parent b359916 commit 92531ce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions webapi/src/main/resources/logback.xml
Expand Up @@ -38,6 +38,7 @@
<logger name="org.knora.webapi.util.cache" level="INFO"/>
<logger name="org.knora.webapi.util.PermissionUtilADM" level="INFO"/>
<logger name="org.knora.webapi.update.UpdateRepository" level="INFO"/>
<logger name="org.knora.webapi.routing.AroundDirectives" level="INFO"/>
<logger name="org.knora.webapi.routing.Authenticator" level="INFO"/>
<logger name="org.knora.webapi.routing.JWTHelper" level="INFO"/>
<logger name="org.knora.webapi.routing.v1.AssetsRouteV1" level="INFO"/>
Expand Down
Expand Up @@ -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
}
}
Expand Down

0 comments on commit 92531ce

Please sign in to comment.