Log4j DailyRollingFileAppender vs ConsoleAppender performance
We're using Log4j v1.2.14. We're already using org.apache.log4j.ConsoleAppender and now we've a requirement/need开发者_如何学C to have daily rotating logs in place. Hence, we're planning to use org.apache.log4j.DailyRollingFileAppender to have daily rotating logs.
My question is, is DailyRollingFileAppender an additional overhead/have performance impact over ConsoleAppender, because it has to additionally check for whether the file has to be rotated/rollover in each print statement?
Any opinions/user experience are also appreciated.
Your arguments are correct and logic dictates that an overhead/performance impact exists. How much? You should measure it by yourself if you're afraid of the performance hit.
It really depends on how many logging statements you have. Lots of debugging statements are the worst because they can impact performance, unless you are using guards of type logger.isDebugEnabled()
.
If you can afford it, I'd suggest switching to slf4j with Logback as underlying implementation. Logback's main focus is speed and it seems to go to great lengths to make sure it's faster than other logging systems.
精彩评论