Since I spent sometime a couple months ago putting together a presentation on logging in Java, I thought I’d submit a proposal to JavaOne this year. Here’s the proposal I wrote up:
Logging in Java ™ with java.util.logging
This presentation shows you how and why to use the logging API that’s
bundled in the core J2SE library. You’ll learn the basics of logging
and configuring, advanced logging and configuration, how to tailor
logging to your needs, and best practices for logging.
We’ll go beyond the standard documentation available in the J2SE and
on the web, using plenty of examples to explain pragmatic ways to
quickly and effectively use the logging API in your code.
The built in logging API has been available in the J2SE for several
years, but consistent and knowledge use of this API is sparse. This
despite both the richness and simplicity of logging, not to mention
the consistency and portability benefits of using the bundled logging
Logging is vital for both quick debugging during development and once
your software has been deployed onto hosted servers or in the field to
customers. Oftentimes all that stands between you and hours of
debugging over the phone is the ability to quickly use logging to
diagnose problems remotely. Attending this session will help save you
from those tedious and costly hours, keeping you and your customers
The presentation follows the outline below:
What logging code looks like
A quick dive into what logging with the logging API actually looks like in
code and as output.
When and why to log
Why programmers should bother to thoroughly put logging in their applications:
the primary reason being that once your application is run in a non-developer
environment, in production, it becomes almost impossible to debug. As a result,
customers get frustrated as problems take “forever” to fix, and companies spend
too much time and money diagnosing problems in the field.
The Logging API
This section introduces the different concepts in the logging API: log
levels, the different log messages, handlers, formatters, etc.
It also covers best practices in logging, such as when to double check
the logging level for performance, using argument’ed messages, logging
exceptions, and how to determine where in the code to log.
Finally, this section covers how to configure logging using the
default flat files, at runtime, and with the newly available logging
MBean. Knowing how to properly configure logging, especially during
runtime is an invaluable skill.
This section contains many code examples that illustrate the points.
This section covers the customizations that can be made in the logging
API, such as custom handlers and formatters, as well as some
extensions to logging, such as context loggers that take care of
logging tedious to code, but vital to debug, information.
A brief section covers using Aspect Oriented Programming to help weave
logging in; pit-falls of an AOP approach are also covered.
Logging Grab Bag, Tip and Tricks
The last section collects together a “Top 10” style list of tips and tricks
with the logging API.
If you’re interested in taking a look at it, there’s a draft of the presentation available.
And, of course, if you’re interested in me giving the presentation, feel free to contact me and we’ll work something out: I’m sure it’d be fun ;>