Writing effective log messages

A log system is a mechanism that allows you to write information to one or more destinations. A Logger has the following components:

  • One or more handlers: A handler will determine the destination and the format of log messages. You can write log messages to the console, a file, or a database.
  • A name: Usually, the name of a Logger used in a class that's based on the class name and its package name.
  • A level: Log messages have a level associated that indicates its importance. A Logger also has a level used to decide what messages it is going to write. It only writes the messages that are as important as, or more important, than its level.

You should use the log system with the following two main purposes:

  • Write as much ...

Get Java 7 Concurrency Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.