Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Exception and Error-Log (Server Side)

Exception and Error-Log (Server Side)

Explains basis of exception and error-log, and proposes to collect all related information to one log record for intuitive debugging.

Kengo TODA

May 21, 2016
Tweet

More Decks by Kengo TODA

Other Decks in Technology

Transcript

  1. AGENDA What is error-log and exception? Why we need error-log

    and exception? How we need to use them? Appendix: How to use log levels?
  2. SLF4J PLACEHOLDER Placeholder is effective to optimise performance Logging library

    will invoke #toString() only when they need. It also makes log format intuitive. Logging library will concat them only when they need. No need to wrap by 
 if(logger.isXxxEnabled()){…}
  3. WHY WE NEED THEM? Error log is necessary to make

    system easy to understand. Even though you don’t know internal implementations, log tells you what is problem and which action you should take.
  4. WHY WE NEED THEM? Exception is necessary to tell problem

    to your caller. If you expect caller does proper recovery, provide enough information to recover.
  5. TELL ENOUGH INFO Developer and system administrator want to know

    problem and next action, so log necessary information to check their usage and reproduce problem for debugging.
  6. COLLECT INFO TO ONE PLACE Even if you use two

    or more log records to tell information, developer and system administrator don’t know it and they may pick only one log record to handle problem.
  7. COLLECT INFO TO ONE PLACE Use cause and suppressed exception

    to collect related information to one place (log record), then developer and system administrator don’t lose important information.
  8. CAUTION Be careful: do not log personal and/or sensitive information

    (e.g. credit card number). Ensure that your framework logs exceptions thrown by your code, or you’ll lose valuable information. Too many log makes system really slow, costly and hard to maintain. Use proper log level to reduce needless logs.
  9. WRAP UP Error-log is for telling WHY & next ACTION

    Cause and SuppressedException help you to collect related information to one log record
  10. HOW TO CHOOSE LOG LEVEL debug/trace log: To debug/trace running

    system. It might affect performance of system. Basically disabled in production env but we may enable it only in specific class/package. info log: To log data which should be checked by system or administrator later. It should not affect performance of system. warn log: To tell minor problem to system and/or administrator. The definition of ‘minor’ depends on development policy or log monitoring policy. error log: To tell major problem to system and/or administrator. The definition of ‘major’ depends on development policy or development policy or log monitoring policy. fatal log: To tell severe problem to system and/or administrator. The definition of ‘severe’ depends on development policy or log monitoring policy. Really complex and many ‘it depends’
  11. KEY POINTS Is your information for system administrator (including log

    collector)? Then use INFO, WARN, ERROR or FATAL. Others are only for developers. Understand your policy to monitor logs, then you will find proper level for your log. If you have no policy to decide log level yet, refer Log4j’s definition for each levels.