Get all updates of Java4s
Follow Us: Email 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 Author ♦

Java4s_Author
sivateja@java4s.com
Full Stack( Java/J2EE & UI/UX ) Developer and founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog. 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.
What would you like to learn today?
Browse these popular technologies
Hibernate spring struts Servlets ajax Log4j jQuery Json Core Java Web Services AngularJs
Most Recent Tutorials
Hibernate_Logo Hibernate Recent Posts Spring_Logo Spring Recent Posts Struts_Logo Struts Recent Posts
Useful Links Current & UpComing Tutorials
Upcoming
  Web Services [ SOAP ], JSP
Contact | About Us | Privacy Policy | Advertise With Us

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