O'Reilly logo

EJB 3.1 Cookbook by Richard M. Reese

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using logging within an EJB

Logging is a useful technique for recording exceptions and significant events which occur during the execution of an application. While there are many different logging APIs available, we will focus on those classes found in the java.util.logging package. If you are interested you may find alternate logging technologies such as log4j (http://logging.apache.org/log4j/1.2/) or the Simple Logging Facade for Java (SLF4J) (http://www.slf4j.org/) to be useful.

Getting ready

The process of creating using a logger involves:

  1. Importing the java.util.logging package
  2. Using the Logger class' static method getLogger to obtain an instance of a logger
  3. Using methods of the Logger to record application data
  4. Optionally, various filters, handlers, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required