From c33ea092652c44301db770f1db4a7243eb6b2363 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Wed, 15 Sep 2021 08:45:55 +0200 Subject: optimize Apache CXF logging handler --- .../auth/eidas/v2/utils/LoggingHandler.java | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'eidas_modules/authmodule-eIDAS-v2/src/main/java/at') diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/LoggingHandler.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/LoggingHandler.java index 70290cd3..10acf3ad 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/LoggingHandler.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/LoggingHandler.java @@ -41,17 +41,23 @@ public class LoggingHandler implements SOAPHandler { @Override public boolean handleMessage(SOAPMessageContext context) { - final SOAPMessage msg = context.getMessage(); - final ByteArrayOutputStream bos = new ByteArrayOutputStream(); + // only perform operations if logging is on trace level + if (log.isTraceEnabled()) { + final SOAPMessage msg = context.getMessage(); + final ByteArrayOutputStream bos = new ByteArrayOutputStream(); + final boolean request = ((Boolean) context + .get(SOAPMessageContext.MESSAGE_OUTBOUND_PROPERTY)).booleanValue(); + try { + msg.writeTo(bos); + log.trace("{} Web-Service with content: {}", + request ? "Requesting to" : "Response from", bos.toString("UTF-8")); - try { - msg.writeTo(bos); - log.trace(bos.toString("UTF-8")); - log.trace(new String(bos.toByteArray(), "UTF-8")); - - } catch (final Exception e) { - log.trace(e.getMessage(), e); + } catch (final Exception e) { + log.trace(e.getMessage(), e); + + } } + return true; } -- cgit v1.2.3