A Comprehensive Log4J Configuration Properties File

el/2024/5/23 2:26:27

转自:

http://www.blogbus.com/blogbus/blog/diary.php?diaryid=278262

A Comprehensive Log4J Configuration Properties File

#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 PROPERTIES #######----------------------!
###############################################################################
# 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 are searched first and  !
! then this file.                                                             !
!-----------------------------------------------------------------------------!
!-----------------------------------------------------------------------------!
! Configure log4j's operation at the meta level                               !
!-----------------------------------------------------------------------------!
! Observe log4j parsing this file
! 观察log4j解析这个文件 #log4j.debug=true
! Set this to false for log4j to actually obey the log4j.disable property(next) ! 使得下面的log4j.disable不会被重新设置
#log4j.disableOverride=false ! Disable all logging in all categories for messages with priority equal to ! or lower than the one given here
! 设置全局优先级 #log4j.disable=INFO !-----------------------------------------------------------------------------! ! Configure categories (loggers) ! !-----------------------------------------------------------------------------! ! ROOT CATEGORY (Usually sufficient to set this one only) ! Here, 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) ! Here, 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) 输出到终端 #log4j.appender.dest1=org.apache.log4j.ConsoleAppender #log4j.appender.dest1.ImmediateFlush=true ! WRITE LOG TO A FILE, ROLL THE FILE AFTER SOME SIZE 输出到日志文件,在到达某个大小的时候进行回滚 #log4j.appender.dest2=org.apache.log4j.RollingFileAppender ! This appender will only log messages with priority equal to or higher than ! the one specified here #log4j.appender.dest2.Threshold=ERROR ! Specify the file name (${property_key} gets substituted 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 输出到日志文件,每周进行回滚 #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 MESSAGES IN THE FORM OF AN HTML TABLE #log4j.appender.dest3.layout=org.apache.log4j.HTMLLayout ! Include Java file name and line number (Default is false) #log4j.appender.dest3.layout.LocationInfo=true ! Set <title> tag (Default: Log4J Log Messages) #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 yyyy 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-------------------------------! ! %-any_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 ! !----------------------------NullAppender OPTIONS-----------------------------! !#log4j.appender.dest1.Threshold=INFO ! !---------------------------ConsoleAppender OPTIONS---------------------------! !#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 ! !-------------------------RollingFileAppender 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.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 ! !-------------------------------HTMLLayout OPTIONS----------------------------! !#log4j.appender.dest3.layout.LocationInfo=true !#log4j.appender.dest3.layout.Title=My app title ! !--------------------------------XMLLayout OPTIONS----------------------------! !#log4j.appender.dest3.layout.LocationInfo=true !-----------------------------------------------------------------------------!

http://www.ngui.cc/el/5239528.html

相关文章

JBuilder 2005代码审查功能体验

JBuilder 2005代码审查功能体验 [文章信息]作者:陈雄华时间:2005-01-04出处:天极网责任编辑:方舟 [文章导读]代码审查作为JBuilder 2005强大的新特性闪亮登场&#xff0c;直指编码中的软肋 <script languageJavaScript> </script> <script languageJavaScript s…

作者写书自己出版的一个讨论

Why Shouldn’t Authors Self-Publish? Maybe I’m a bit nave about the whole book publishing industry, but I can’t really figure out why most tech author use major publishing houses to release their books. I have only work on one book (as a tech reviewer…

2004手机游戏年终点评(推荐,转贴)

2004手机游戏年终点评(推荐&#xff0c;转贴&#xff09; 如果说在一年前&#xff0c;手机游戏给大多数人的第一印象还是贪吃蛇 、猜数字的话&#xff0c;那么现在&#xff0c;任何一个对IT或对游戏稍有关心的人 &#xff0c;都对这一年间手机游戏在国内的井喷之势有所耳闻。…

WAP 建置 Java 應用(sendRedirect不能保持session)

WAP 建置 Java 應用 內文: 背景︰J2EE 和 WAPWAP 應用的設計考慮事項建立起範例應用關於程式碼結論參考資料關於作者 充分利用現有的 EJB 使行動人力資源變得強大 Aashish Patil ( ash01vsnl.net) 理科碩士研究生&#xff0c;計算機科學系&#xff0c;Southern California 大學…

如果使用maven genapp来产生struts应用的模版有错误

试试把C:/Documents and Settings/xxx/.maven/cache/maven-genapp-plugin-2.2删除 有可能前一个版本的genapp插件过时了

maven hibernate:schema-export need classpath info to location classes

maven.hibernate.input.dir${maven.xdoclet.hibernatedoclet.destDir},${maven.build.dir}/classes

Symantec SPBBCSvc SPBBCSvc.exe Symantec Internet Security Service

Symantec SPBBCSvc SPBBCSvc.exe Symantec Internet Security Service

“摩根”启示录

“摩根”启示录 1 “摩根”公司创立 “摩根”公司创立于2006年4月1日的一次“战略管理与决策” 沙盘模拟训练。非常感谢公司给我们这样一次全面体验企业经营的机会。 1.1 沙盘模拟 沙盘模拟训练源自西方军事上的战争沙盘模拟推演&#xff0c;完全不同于传统的…

jira keygen

转载来源不明&#xff0c;仅供大家了解其中的java相关的知识 JIRA可真是个好东西啊,自定义能力超强,虽然主要是用来做bug跟踪管理的,但是很容易的就可以改造成项目管理系统.只可惜是要收费的,为了使用它,sorry啊,只好下载了一个注册机.不过下载的注册机是JIRA3.0版的,现在的JI…

Opera访问wml等wap页面的较好版本

版本信息版本 8.53 编制 7722 平台 Win32 系统 Windows XP Java Sun Java Runtime Environment version 1.5 XHTML语音 插件未装入 不要急于升级到其他的高版本&#xff0c;此版本在解析onevent和ontimer等脚本方面很完善。