WPS icon indicating copy to clipboard operation
WPS copied to clipboard

Remove string concatenation from log statements

Open nuest opened this issue 10 years ago • 7 comments

String concatenation in log statements decrease performance, they should be replaced with placeholders. Search the whole workspace with the regexes LOGGER*" + and log*" +

nuest avatar Aug 16 '14 00:08 nuest

:+1: What's your preferred way of tokenizing logging statements? Have you looked at http://docs.oracle.com/javase/7/docs/api/java/text/MessageFormat.html ?

isuftin avatar Aug 16 '14 14:08 isuftin

I have to admit I have not considered formatting. I'd start with using the slf4 parameterized messages: http://www.slf4j.org/faq.html#logging_performance But these only call toString(() on objects afaik.

nuest avatar Aug 16 '14 15:08 nuest

If not using it yet, have you given consideration to using Logback over SLF4J and using the Async logging appender? http://logback.qos.ch/manual/appenders.html#AsyncAppender

isuftin avatar Aug 16 '14 15:08 isuftin

We're actually using logback, but behind SLF4J as an abtraction layer.

AsyncAppender could probably be quickly configure in the WPS's logback XML config file.

nuest avatar Aug 18 '14 13:08 nuest

Agreed. My only hesitation in using it is it seems to drop TRACE, DEBUG and INFO levels of logging if its queue is 80% full. There's that tradeoff.

isuftin avatar Aug 18 '14 13:08 isuftin

Well, I guess we could leave the old configuration in place and leave a comment there to switch back to that one if issues arise that require full TRACE log. But in a productive environment, you're probably not logging at DEBUG level anyway, right? And that is where the dropping makes sense because you're not stalling the application because of logging. But I'd have to read more about this to give a real opinion here, this is mostly guessing :smile:

nuest avatar Aug 18 '14 13:08 nuest

I agree. It does also drop INFO, though. :(

isuftin avatar Aug 18 '14 13:08 isuftin