Tutorialspoint examples

Learn java tutorial with examples for beginners online

Log4j example using log4j properties file

Let us discuss the use of Log4j with the help of below example. In this example we use log4j.properties file for Log4j configurations.



import org.apache.log4j.Logger;
 * This class is used to show the use of 
 * Log4j with the log4j.properties file.
 * @author javawithease
public class Log4jTest {
	//Get the Logger object.
	private static Logger log = Logger.getLogger(Log4jTest.class);
	public static void main(String[] args) {	
		//logger messages
		log.debug("Log4j debug message test.");
		log.info("Log4j info message test.");		


log4j.rootLogger=DEBUG, CA
#Set Console Appender
#CA uses PatternLayout


Log4j debug message test.
Log4j info message test.

Download this example.
Next Topic: Log4j example using log4j xml file.
Previous Topic: Log4j example.

Related Topics:

How to build java project using ant in eclipse?
JAXB marshalling – convert java object to xml example.
How to create pdf file in java using iText jar?
Generics class example.
OGNL in struts 2.
Hibernate One-to-One Mapping using xml.
Send inline image in email using JavaMail API.
Quartz 2 JobListener example.


Download tutorialspointexamples Android App
Copyright © 2018 Tutorialspoint examples DMCA.com Protection Status