Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Tips for Proper Application Logging

  1. Use the appropriate tools for logging. SLF4J is the best logging API available, mostly because of a great pattern support.
  2. SLF4J provides logging levels for you.
    1. ERROR – something terribly wrong had happened, that must be investigated immediately. No system can tolerate items logged on this level. Example: NPE, database unavailable, mission critical use case cannot be continued
    2. WARN – the process might be continued, but take extra caution. Actually I always wanted to have two levels here: one for obvious problems where work-around exists (for example: “Current data unavailable, using cached values”) and second (name it: ATTENTION) for potential problems and suggestions.
    3. DEBUG – Developers tool to keep the track of the flow of operation in the application.
  3. Exactly specify the log message so that it reflect what the method does. 
    i.e. 
  4. Use logger.debug("") to show the flow of the operations (name of method and what it does) after logical operations in a method with an appropriate message. This helps to easily figure out where the application is stuck.   
  • No labels

0 Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.