O'Reilly logo

Java 9 Concurrency Cookbook - Second Edition by Javier Fernández González

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

How it works...

In this recipe, you used the Logger class provided by the Java logging API to write log messages in a concurrent application. First of all, you implemented the MyFormatter class to assign a format to the log messages. This class extends the Formatter class that declares the abstract format() method. This method receives a LogRecord object with all of the information of the log message and returns a formatted log message. In your class, you used the following methods of the LogRecord class to obtain information about the log message:

  • getLevel(): Returns the level of a message
  • getMillis(): Returns the date when a message was sent to a Logger object
  • getSourceClassName(): Returns the name of a class that had sent the message ...

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