Simple Layout

Simple Layout

SimpleLayout is able to prepare logging messages with “LEVEL – Log_Message”. Log4j has provided a pre-defiend class to represent Simple Layout,that is, org.apache.log4j.SimpleLayout

log4j.properties

log4j.rootLogger = ALL, FILE
log4j.appender.FILE = org.apache.log4j.FileAppender
log4j.appender.FILE.file = /home/ashok/loggers/ashok.log
log4j.appender.FILE.layout = org.apache.log4j.SimpleLayout
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"); 
	}
}

Output

TRACE - This is trace message
DEBUG - This is debug message
INFO - This is info message
WARN - This is warn message
ERROR - This is error message
Simple Layout
Scroll to top