Can view the tutorials best in Google Chrome, Mozilla Firefox, Opera, higher version of Internet Explorer

How To Create Log4j.properties File

Log4j » On Feb 27, 2012 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.

 







By [ Java/J2EE Developer & Web Designer ]
Founder of Java4s.com - Indian, lives in United States. You can contact me at sivateja@java4s.com


Comments

One Response to “How To Create Log4j.properties File”
  1. Rakshitha says:

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

Name*
Mail*
Website



By posting your answer, you agree to our comments policy.
Most Recent Tutorials
Hibernate Recent Posts
Spring Recent Posts
Struts Recent Posts
Recomandded Links Current & UpComing Tutorials Java4s.com
Tutorials Online :
spring Hibernate struts Json Ajax Log4j Log4j
coreJava Servlets


UpComing :
JSP, Web Services [ In Progress ]
Java4s is optimized for learning java technologies, all the examples in this site are constantly reviewed to avoid errors. While using this site you agree to have read and accepted our terms of use and privacy policy
Especially i have prepared this blog by keeping fresher's in mind, however it will be very useful for real time developers too.


© 2014 Java4s All rights reserved. | strPro4Tut v(2.0) Theme designed by Team Java4s.