Logging Best Practices

Recently I helped developers and QA teams to identify the cause of performance issues in one of Weblogic applications and I noticed that current way of using log4j framework for all Weblogic applications is unsystematic and inconsistent:

  • loggers, appenders and layouts set up differently for different applications
  • applications do not have properly defined SMTPAppender appender (no notification is sent when error is happening)
  • applications continue to write to Weblogic server logs by using System.out.print or printStackTrace() instead of using logger call.

I proposed the following solution and I have to implement it as soon as possible

  • Create common log4j template
  • define proper logger, appenders, layouts
  • applications should define their own log file outside server logs
  • application should broadcast error messages via email
  • Configure QuickBuild to use new log4j template
  • Update log4j template for all WebLogic applications
  • Enforce correct and consistent invocation of logging framework in application code by integrating static code analysis tools in SDLC ( for example JTest, PMD, FindBugs)
  • Include verification for proper application logging and error notifications to test plans
  • Acquire log reader tools (for example Chainsaw, LogMX, SuperTracer)

No comments: