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 format of the log messages. You can write log messages in the console, a file, or a database.
  • A name: Usually, the name of a Logger used in a class is based on the class name and its package name.
  • A level: Log messages have different levels that indicate their importance. A Logger also has a level to decide what messages it is going to write. It only writes messages that are as important as, or more important, than its level.

You should use the log system because of the following two main reasons:

  • Write as ...

Get Java 9 Concurrency Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.