log4j.properties explained part 2

log4j.properties explained - appenders, layouts - Pattern and HTML layout, package logging level.

In each appender you must set layout. Usually you will use PatternLayout, where you define a pattern of a log message, but there are also other layouts, such as HTMLLayout.

You can even print logging information to more than one appender at once.

Another cool feature is, that you can customize logging level for different packages. If you use external frameworks in your application such as Spring or Hibernate, if you turn on DEBUG logging level for whole application, you will get significant amount of logging information from these frameworks. Usually you don't need that much information. Instead set root logger level for example to WARN and set your own package to another logging level using log4j.category, for example DEBUG.


comments powered by Disqus


Free online Java web application examples

Want to develop whole web applications which use database, security and more? See my github account, where are lot's of example projects: