[MAGNOLIA-353] Using if statements before log4j calls Created: 28/Apr/05  Updated: 10/May/05  Resolved: 10/May/05

Status: Closed
Project: Magnolia
Component/s: core
Affects Version/s: 2.1 Final
Fix Version/s: 2.1 Final

Type: Improvement Priority: Minor
Reporter: Nicolas Modrzyk Assignee: Sameer Charles
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Date of First Response:

 Description   

It would be nice to follow the followin:

if(logger.isDebugEnabled()

{ logger.debug("Entry number: " + i + " is " + String.valueOf(entry[i])); }

That would actually minimize the cost of logging in production environment.
I've noticed there is a lot of output on the INFO level, and apply the test statement for each log call could greatly improve the reponsiveness.

I could also work on it whenever ...



 Comments   
Comment by Boris Kraft [ 28/Apr/05 ]

I doubt that this is a big hit on performance. Messure before you optimize. And use log4j config to turn off the writing of these messages if you don't need them.

I think that generally the additional code clutter is not worth the benefit. In places where code is iterated over heavily, I suggest that devs use the suggested pattern at their descretion.

Comment by Sameer Charles [ 28/Apr/05 ]

Its true that it wont log it if debug is not enabled BUT, it will still compute the parameter
for instance - log.debug(varA + varB + varC) it wont log if disabled but it will concatinate all
three variables before determining if it has to be logged or not.
Also, I prefer moving most log.info to log.debug together with isDebugEnabled()

Comment by Sameer Charles [ 10/May/05 ]

added where necessary, from now on we will just have to take care whenever using loger

Generated at Mon Feb 12 03:16:35 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.