Newsletter

How To Create Log4j.properties File

Log4j » on Feb 27, 2012 { 6 Comments } By Sivateja

In previous program, i have used FileAppender.  But if i would like to change my appender to JDBCAppender, i have to open my java file and do the modifications and need to recompile.  We can avoid this by  writing one .properties file.

By default the file name would be log4j.properties. This properties file stores data in the form of key, values pairs, in this file keys are fixed but values are our own.  We can include all the log4j related properties into this file.

log4j.properties

log4j.rootLogger=DEBUG,CONSOLE,LOGFILE

log4j.appender.CONSOLE=
log4j.appender.CONSOLE.layout=
log4j.appender.CONSOLE.layout.ConversionPattern=

log4j.appender.LOGFILE=
log4j.appender.LOGFILE.File=
log4j.appender.LOGFILE.MaxFileSize=
log4j.appender.LOGFILE.layout=
log4j.appender.LOGFILE.layout.ConversionPattern=

will see one example.

 

​​

You Might Also Like

  ::. About the Author .::

Java4s_Author
Sivateja Kandula - Java/J2EE Full Stack Developer
Founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog, Love Java and UI frameworks.
You can sign-up for the Email Newsletter for your daily dose of Java tutorials.

Comments

6 Responses to “How To Create Log4j.properties File”
  1. Rakshitha says:

    neat and clear explanations…thank u so much..best tutorials for beginners

  2. vijay says:

    clear cut explanation

  3. vivek says:

    log4j.rootLogger=DEBUG,CONSOLE,LOGFILE

    These name are predefined or user defined ?
    Details about layout.ConversionPattern foramts ?

  4. K. Saidulu says:

    very very clear data for every thing … nice for beginners and experience also.

  5. sharmila says:

    Hi..This is very helpful website..
    Can You please describe about Web Server And Application Server,as well about TomcatEE server

  6. srinivas says:

    hi , properties file xml lo cheyala or any other is there

Name*
Mail*
Website



By posting your answer, you agree to our comments policy.
Most Recent Posts from Top Categories
Spring Boot Hibernate Spring
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2024 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.