Reputation: 2628
Does logging decreases application performance? and how to restrict display-tags logs to be printed in log files?
eg. my log file has below logs
[2012-06-20 15:52:06,290] org.displaytag.tags.TableTag isFirstIteration 684 - [data] first iteration=true (row number=1)
[2012-06-20 15:52:06,290] org.displaytag.tags.TableTag isFirstIteration 684 - [data] first iteration=true (row number=1)
[2012-06-20 15:52:06,290] org.displaytag.tags.TableTag isFirstIteration 684 - [data] first iteration=true (row number=1)
[2012-06-20 15:52:06,290] org.displaytag.tags.TableTag isFirstIteration 684 - [data] first iteration=true (row number=1)
why the above is in log file?
log.properties file
# Log4j configuration file.
log4j.rootCategory=DEBUG, A1
# Available levels are DEBUG, INFO, WARN, ERROR, FATAL
#
# A1 is a ConsoleAppender
#
log4j.appender.A1 = org.apache.log4j.RollingFileAppender
log4j.appender.A1.File = C:/LogInfo/logfile.log
log4j.appender.A1.MaxFileSize = 100MB
log4j.appender.A1.MaxBackupIndex=50
log4j.appender.A1.layout = org.apache.log4j.PatternLayout
log4j.appender.A1.append = true
log4j.appender.A1.layout.ConversionPattern = [%d] %C %M %L - %m%n
log4j.appender.A1.Threshold = DEBUG
how to stop (org.displaytag.tags.TableTag) these kind of logs to be printed in log files
Upvotes: 13
Views: 27352
Reputation: 718788
Does logging decreases application performance?
Yes. How much it does depends on a number of factors; see below.
and how to restrict display-tags logs to be printed in log files?
By changing the ConversionPattern in the logging properties
why the above is in log file?
Because:
debug(String)
) with that message, andTo improve performance:
Logger.debug(...)
call inside an if
statement that checks that debug logging is enabled. This saves the cost of assembling the log message in cases where it won't be needed; see In log4j, does checking isDebugEnabled before logging improve performance?.You can also throttle logging at the Logger
level ... as described in the log4j documentation. In fact, the documentation answers most of the questions that you asked, and has a lot of detail on the topics of logging performance and logging configuration.
Upvotes: 11
Reputation: 2242
You can restrict junk logs like this. Set the root logger as INFO so that unnecessary debug logs won't come and fill up your log file.
log4j.rootCategory=INFO, A1
If you want specific class or package to give out DEBUG logs you can do it like this.
log4j.logger.org.hibernate.event.def.DefaultLoadEventListener=DEBUG,A1
The above will print DEBUG level logs from the class DefaultLoadEventListener in your log file along with other INFO level logs.
Upvotes: 0
Reputation: 326
how about?
log4j.category.org.displaytag.tags.TableTag=ERROR, A1
Upvotes: 0
Reputation: 533500
Logging can be 30% of you cpu time or more. In terms of jitter, it as large (and more often) than your GC delays.
A simple way to reduce overhead is to use the Pattern to turn off where you are logging each message from. In your case this is %C %M and %L as it has to take a stack trace (of the entier stack) to get this information.
Upvotes: 1
Reputation: 47665
Short answer: yes, it decreases application performance as it uses some CPU cycles and other resources (memory, etc).
See also this question : log4j performance
Upvotes: 3
Reputation: 6969
Yes they do. That's why you should only log an error or something that must absolutely be logged. You can also log information helpful for debugging in the debug channel so it won't affect production performance.
Upvotes: 0