Logging is very important part of any programming language. It gives important information to developers to understand the program behavior. Its almost next to impossible to debug issues without logs. So logs are very important but logging itself is overhead for any program. It shares valuable CPU time, consume program memory, perform I/O operations. So Logs are necessary evils.
Various logging framework provide various techniques to reduce these overhead. Common techniques to improve performance
Test Code using "java.util.logging.Logger"
Test Results "java.util.logging.Logger"
Test Results "java.util.logging.Logger"
Test Code using "org.apache.logging.log4j.Logger"
Test Results "org.apache.logging.log4j.Logger"
Conclusion:
Reference:Various logging framework provide various techniques to reduce these overhead. Common techniques to improve performance
- Configuration Techniques
- Set default logging level to Severe
- On demand enable Logging for specific module
- Programming Techniques
- Use discretion while putting log level for evey log
- Check log level before processing logging command
Test Code using "java.util.logging.Logger"
Test Results "java.util.logging.Logger"
Test Results "java.util.logging.Logger"
Test Code using "org.apache.logging.log4j.Logger"
Test Results "org.apache.logging.log4j.Logger"
Conclusion:
- Apache Logger is more efficient in logging than java default logger.
- String concatenation technique in less efficient than new placeholder technique. [But for log4j placeholder technique is available in log4j 2.0 only.]
- Its very efficient to check log level before logging command for dynamic logs [The logs which require string concatenation or placing values in placeholders ]
- Its inefficient to check log level before logging command for simple/static logs.
http://logging.apache.org/log4j/2.x/performance.html
No comments:
Post a Comment