This section tells you how to create a custom formatter for a logger handler. Java provides two types formatter SimpleFormatter and XMLFormatter. But, the java logging package allows for creating a custom formatter through the logger handler. Here you will see custom formatter that means formatter is created by users or user defined formatter. A logger handler writes log records to another file by using the logger formatter.
Descriptions of program:
Program creates a logger and writes logger records to given file in FileHandler that has append property is true to add content into last of file. Contents are adding into a file to given format in custom formatter. Here, formatter provides the facility to write date into file in 'heading 1' format.
Description of code:
Above is a method of Formatter class that returns string types formatter records. This method takes a argument which is any type of handler.
Here is the code of program:
Posted on: February 22, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles