XML Layout

XML Layout

It able to provide logging messages in the form of XML document. To represent XMLLayout, Log4j has provided a predefined class in the form of “org.apache.log4j.xml.XMLLayout”.

log4j.rootLogger = ALL, FILE
log4j.appender.FILE = org.apache.log4j.FileAppender
log4j.appender.FILE.file = /home/ashok/loggers/ashok.xml
log4j.appender.FILE.layout = org.apache.log4j.xml.XMLLayout
package com.ashok.log4j;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * 
 * @author ashok.mariyala
 *
 */
public class TestLog4J {
	private static final Logger LOG = LoggerFactory.getLogger(TestLog4J.class);
	public static void main(String[] args) {
		LOG.trace("This is trace message"); 
		LOG.debug("This is debug message");
		LOG.info("This is info message"); 
		LOG.warn("This is warn message"); 
		LOG.error("This is error message"); 
	}
}
XML Layout


Scroll to top