# Log4j.debug = true
# log4j.disable = Fatal
# Log4j.additivity.testlogging = false
Log4j.rootcategory =, DEST1
Log4j.category.testlogging = debug, dest1
log4j.appender.dest1 = org.apache.log4j.ConsoleAppender
# Log4j.appender.dest1.layout = org.apache.log4j.SimpleLayout
log4j.appender.dest1.layout = org.apache.log4j.PatternLayout
# Log4j.appender.dest1.layout.ConversionPattern =% - 5p% l% x:% m% n
! ---------------------- ####### End of property ####### ---------- ------------!
################################################## ###########################################
# Below I document in more detail how to write a log4j configuration file. #
# Selectively Copy Lines Beginning with #, Paste and UNcomment Them Above. #
################################################## ###########################################
! ------------------------------------------------- ----------------------------!
Place this file anywhere in classpath!
Appenders Are Additive by Default.!
! Priorities are inherited until overridden in a category.!
! In $ {property_key}, the value of the key can be defined as a system!
! Property or in this file itself. System Properties Area Searched First and!
!..!
! ------------------------------------------------- ----------------------------!
! ------------------------------------------------- ----------------------------!
CONFIGURE LOG4J's Operation At The Meta Level!
! ------------------------------------------------- ----------------------------!
Observe log4j paarsing this file! Watch log4j parsing this file # log4j.debug = true! Set this to false for log4j to actual Obey the log4j.disable property (next)
! Make the following log4j.disable will not be reset # log4j.disableoverride = false
! Disable all logging in all categories for Messages with Priority Equal To
Or Lower Than The One Given Here! Set global priority
# log4j.disable = info
! ------------------------------------------------- ----------------------------!
! Configure Categories (Loggers)!
! ------------------------------------------------- ----------------------------!
Root Category (Usually Sufficient To Set this One ONLY)
!, Logs Messages with priority debug (default) or higher
# log4j.rootcategory =, DEST1
OR,
# Log4j.rootcategory = debug, dest1, dest2
! Your Categories (To Customize Logging Per Class / PKG / Project / ETC)
!, Overrides Ancestor's Priority and Makes It Warn or Higher for this cat.
# log4j.category.testlogging = WARN, DEST3
OR,
# log4j.category.testlogging = debug, DEST3
! -------- Don't do this !!! Appenders Are Additive by Default !!! ---------------!
It will Write the Same Log Message TWICE to DEST1. ONCE for Root, Then For!
this category.!
! # Log4j.category.testlogging = debug, dest1, dest3!
! If you do not want additivity for this category, Say So!
! # Log4j.additivity.testlogging = false!
! ------------------------------------------------- ----------------------------!
! ------------------------------------------------- ----------------------------!
! Configure appenders (log destinations / targets) and their options !! ------------------------------------------------------------------------------------------------------------------ ----------------------------------------!
Write to console (stdout or stderr) output to the terminal
# log4j.appender.dest1 = org.apache.log4j.consoleAppender
# log4j.appender.dest1.immediateflush = true
! Write log to a file, roll the file instator output to the log file, roll back when reaching a size
# log4j.appender.dest2 = org.apache.log4j.rollingfileAppender
! This appender will only log message with priority equal to or higher Than
! The one specified here
# log4j.Appender.Dest2.threshold = Error
! Specify The File Name ($ {property_key} gets substitudeid with its value)
# Log4j.Appender.dest2.file = $ {java.home} /log4j.log
! Don't append, overwrite
# log4j.appender.dest2.append = false
! Control The Maximum Log File Size
# log4j.appender.dest2.maxfilesize = 100kb
! Keep Backup File (s) (Backups Will Be in filename.1, .2 etc.)
# log4j.Appender.Dest2.maxbackupindex = 2
Write log to a file, Roll The File Every Week Outputs to the log file, rollback weekly
# log4j.appender.dest3 = org.apache.log4j.dailyrollingFileAppender
Specify the file name
# log4j.Appender.Dest3.file = log4testlogging2.html
! Control The Maximum Log File Size
# log4j.Appender.Dest3.maxfilesize = 300kb
Rollover Log File At the Start of Each WEEK
# Log4j.Appender.Dest3.datepattern = '.' YYYY-WW
! ------------------------------------------------- ----------------------------!
"Configure appender layouts (log formats) and their options!
! ------------------------------------------------- ----------------------------!
Use Simple Log Format (E.G. Info - Your Log Message)
# log4j.Appender.Dest1.Layout = org.apache.log4j.simplelayout! Use a c printf style pattern to format log message
# log4j.appender.dest1.Layout = org.apache.log4j.patternlayout
! For a pattern layout, Specify THE PATTERN (Default IS% M% N Which IS Fastest)
# log4j.Appender.dest1.Layout.conversionPattern =% - 5P:% m% N
OR,
# log4j.Appender.dest1.Layout.conversionPattern =% - 5P% 6.10R [% T]% x (% F:% L) -% M% N
# log4j.Appender.dest2.Layout = Org.apache.log4j.patternlayout
# log4j.Appender.Dest2.Layout.conversionPattern = [% D {ISO8601}]% 5P% 6.6R [% T]% x (% f:% L) -% M% N
! Or, (The Pattern Below Will Slow Down Your App)
# log4j.Appender.Dest2.Layout.conversionPattern = [% D {YYYY-MM-DD HH: mm},% 6.6R]% - 5P [% T]% x (% F:% L) -% M% N
! Format log message in the form of an html table
# log4j.Appender.Dest3.Layout = org.apache.log4j.htmllayout
! Incrude Java File Name and Line Number (Default Is False)
# Log4j.Appender.Dest3.Layout.LocationInfo = True
! Set
# Log4j.Appender.Dest3.Layout.title = my app log
! ------------------------------------------------- ----------------------------!
! Pattern Formats Glossary!
! ------------------------------------------------- ----------------------------!
!% n - newline!
!% m - Your log message!
!% P - Message Priority (Fatal, Error, Warn, Info, Debug or Custom)!
!% R - Millisecs Since Program Started Running!
! %% - Percent Sign in Output!
! !! ----------------------- Some more clutter in Your log ------------------ -------!
!% C - Name of Your Category (Logger),% C {2} Will Outputs Last Two Components!
!% T - Name of current thread!
!% x - Nested Diagnostic Context (NDC) (You Supply it!)!
!!
! ------------------------- Slow Performance Formats --------------------- -------!
!% d - date and time, Also% D {ISO8601},% d {date},% d {absolute},!
!% d {hh: mm: ss, sss},% d {DD MMM YYYYY HH: mm: SS, SSS} and so ON!
!% l - shortcut for% F% L% C% M!
!% F - Java Source File Name!
!% L - Java Source Line Number!
!% C - java class name,% c {1} Will Output The Last One Component!
!% M - Java Method Name!
!!
! ----------------------------- Format Modifiers ----------------- --------------!
!%-An_Letter_Above - Left-Justify In min. Width (Default Is Right-Justify)!
!% 20any_Letter_above - 20 char. Min. Width (Pad with spaces if reqd.)!
!% .30any_Letter_above - 30 char. Max. Width (Truncate Beginning if Reqd.)!
!% -10.10R - EXAMPLE. Left-Justify Time Elapsed Within 10-Wide Field.!
! Truncate from Beginning If Wider Than 10 Characters.!
! ------------------------------------------------- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------! -------------------------------------------------- -------!
! Options Glossary!
! ------------------------------------------------- ----------------------------!
! ------------------------- Overall Options for log4J -------------------- -------!
! Specify as command line option: -dlog4j.defaultinitOverride = false
! Specify as command line option: -dlog4j.configuration = app_config.properties
! # Log4j.debug = TRUE
! # Log4j.disable = info
! # log4j.disableoverride = false
! # Log4j.additivity.your.category.name = false
!
! ------------------------------------------- ----------!
! # log4j.Appender.Dest1.threshold = info
!
! -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------!
! # log4j.Appender.Dest1.threshold = info
! # log4j.appender.dest1.immediateflush = true
! # log4j.Appender.Dest1.target = system.err
!
! ----------------------------- FileAppender Options ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ----------!
! # log4j.appender.dest2.threshold = info
! # log4j.appender.dest2.immediateflush = true
! # log4j.Appender.Dest2.file = mylog.txt
! # log4j.Appender.Dest2.append = false
!
! ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---!
! # log4j.appender.dest2.threshold = info
! # log4j.appender.dest2.immediateflush = true
! # log4j.Appender.Dest2.file = mylog.txt
! # log4j.Appender.Dest2.append = false
! # log4j.appender.dest2.maxfilesize = 100kb
! # log4j.appender.dest2.maxbackupindex = 2
!
! ----------------------- DailyRollingFileAppender Options ----------------------!
! # log4j.Appender.Dest2.threshold = info! # log4j.appender.dest2.immediateflush = true
! # log4j.Appender.Dest2.file = mylog.txt
! # log4j.Appender.Dest2.append = false
! # log4j.Appender.Dest2.datepattern = '.' YYYY-WW
!
! ----------------------------- SimpleLayout Options ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------!
** none **
!
! ------------ TTCCLAYOUT OPTIONS (PatternLayout is more flexible) -------------!
! # log4j.Appender.Dest1.Layout.DateFormat = ISO8601
! # log4j.Appender.Dest1.Layout.timezoneId = GMT-8: 00
! # log4j.appender.dest1.Layout.categoryPrefixing = false
! # Log4j.Appender.Dest1.Layout.threadprinting = false
! # log4j.Appender.Dest1.Layout.Contextprinting = false
!
! ---------------------------- PatternLayout Options -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------!
! # log4j.Appender.Dest1.Layout.conversionPattern =% m% N
!
! ------------------------------ HTMLLLAYOUT OPTIONS ------------------------------------------------------------------------------------------------------------------------------------------------------ ------------!
! # log4j.Appender.Dest3.Layout.LocationInfo = TRUE
! # log4j.Appender.Dest3.Layout.title = my App Title
!
! ------------------------------- XMLLayout Options --------------- -------------!
! # log4j.Appender.Dest3.Layout.LocationInfo = TRUE
! ------------------------------------------------- ----------------------------!