In this section we will describe you about HTMLLayout class. This layout outputs events in a HTML table. Appenders using this layout should have their encoding set to UTF-8 or UTF-16, otherwise events containing non ASCII characters could result in corrupted log files.
The HTMLLayout outputs events in a fixed format table. Each row of the table corresponds to an event while five columns: Time, Thread, Level, Logger Category and Message correspond to member fields of the logging event.
In this example we have used FileAppender for appending output into the HTML file.
Here is the example code of HTMLLayout in Log4j :
To run this example code follow these steps :
You will have an HTMLFile.html file as output with the following representation:
Liked it! Share this Tutorial