If you want to generate your logging information in an HTML-formatted file, then you can use org.apache.log4j.HTMLLayout to format your logging information.
The HTMLLayout class extends the abstract org.apache.log4j.Layout class and overrides the format() method from its base class to provide HTML-style formatting.
It provides the following information to be displayed:
HTMLLayout is a very simple Layout object that provides the following methods:
|Sr.No.||Method & Description|
Following is a simple configuration file for HTMLLayout:
Now consider the following Java Example which would generate logging information:
Compile and run the above program. It would create an htmlLayout.html file in /usr/home/log4j directory which would have the following log information:
Log session start time Mon Mar 22 13:30:24 AST 2010
|0||main||DEBUG||log4jExample||log4jExample.java:15||Hello this is an debug message|
|6||main||INFO||log4jExample||log4jExample.java:16||Hello this is an info message|
You would use a web browser to open htmlLayout.html file. It is also important to note that the footer for the </html> and </body> tags is completely missing.
One of the big advantages of having the log file in HTML format is that it can be published as a web page for remote viewing.
Log4j Related Interview Questions
|HTML Interview Questions||HTML 5 Interview Questions|
|AJAX Interview Questions||JSP Interview Questions|
|Quark Xpress Interview Questions||JavaMail API Interview Questions|
|JUnit Interview Questions||Eclipse (software) Interview Questions|
|Apache Ant Interview Questions||Spring MVC Framework Interview Questions|
|Structural Analysis Interview Questions|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.