O'Reilly logo

J2EE™ and Beyond: Design, Develop, and Deploy World-Class Java™ Software by Art Taylor

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

The SingleLineFormatter Class

The SimpleFormatter class in the JDK logging package uses three lines of text to produce a log entry. The previous example demonstrated the use of a custom log output formatter. To produce a more concise log output message, the SingleLineFormatter class we develop here is used to format a message that uses only a single line of text. Attaching a formatter to a Handler object requires an object which implements the Formatter abstract class. For convenience, we choose to extend the SimpleFormatter class, which provides a concrete implementation of the Formatter abstract class, and we extend only the methods whose behavior we wish to alter. The code for this class is shown below.

We first create a class declaration, ...

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