Basically, when writing code, intersperse every major event with a log4j logger call - on parts that may be troublesome add a DEBUG level, and if you want a message for live use/monitoring add a INFO level. Log4J allows this differing level to determine when it should print messages. Hence if your app is breaking, then you restart, setting the logging level to debug. Once it is fixed, you set it back to INFO, or LIVE etc - this saves major time when debugging a failed app after its gone live, or even in test.
Read the docs for more ...