자바 로그 파일 (메모)

3342 단어 자바
1.    : Log4J    C    printf              ,  :(log4j.appender.D.layout.ConversionPattern )
	%m             
	%p        , DEBUG,INFO,WARN,ERROR,FATAL 
	%r              log         
	%c          ,           
	%t                 
	%n            ,Windows   “\r
”,Unix “
” %d , ISO8601, , :%d{yyy- MM- dd HH:mm:ss , SSS}, :2002-10-10 10:10:10 %L , 、 , 。 :Testlog4.main(TestLog4.java: 10 ) 2. (log4j.appender.D.File ) ./ ../ 3. ERROR、WARN、INFO、DEBUG ERROR WARN , session INFO , DEBUG 4. http://www.cnblogs.com/ITEagle/archive/2010/04/23/1718365.html

  ### set log levels ###
 ### set log levels ###
################### 
#    INFO  info  
#  stdout          
#I    info         
#E     error     
#[${webName.root}/WEB-INF/logs/bolihotel-INFO]       WEB-INF/logs/       ,I,E 
###################
#log4j.rootLogger =INFO,stdout		      
log4j.rootLogger =INFO,I,E
 
###        ###
#log4j.appender.stdout = org.apache.log4j.ConsoleAppender
#log4j.appender.stdout.Target = System.out
#log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
#log4j.appender.stdout.layout.ConversionPattern =%d{yyyy-MM-dd hh:mm:ss} [%t:%r] %c:%L-[ %p ]-%m%n

###         ###
log4j.appender.I = org.apache.log4j.DailyRollingFileAppender
log4j.appender.I.File =${webName.root}/WEB-INF/logs/bolihotel-INFO
log4j.appender.I.Append = true
log4j.appender.I.Threshold = INFO
log4j.appender.I.Encoding=UTF-8
log4j.appender.I.DatePattern='-'yyyy-MM-dd'.log'
log4j.appender.I.layout=org.apache.log4j.PatternLayout
log4j.appender.I.layout.ConversionPattern =%d{yyyy-MM-dd hh:mm:ss} [%t:%r] %c:%L-[ %p ]-%m%n

###             ###
log4j.appender.E = org.apache.log4j.DailyRollingFileAppender
log4j.appender.E.File = ${webName.root}/WEB-INF/logs/bolihotel-ERROR
log4j.appender.E.Append = true
log4j.appender.E.Threshold =ERROR
log4j.appender.E.Encoding=UTF-8
log4j.appender.E.DatePattern='-'yyyy-MM-dd'.log'
log4j.appender.E.layout=org.apache.log4j.PatternLayout
log4j.appender.E.layout.ConversionPattern =%d{yyyy-MM-dd hh:mm:ss} [%t:%r] %c:%L-[ %p ]-%m%n

  웹. xml 로 로그 4j 파일 불 러 오기
<context-param>
		<param-name>webAppRootKey</param-name>
		<param-value>webName.root</param-value>
	</context-param>
	<context-param>
		<param-name>log4jConfigLocation</param-name>
		<param-value>/WEB-INF/classes/log4j.properties</param-value>
	</context-param>
	<context-param>
		<param-name>log4jRefreshInterval</param-name>
		<param-value>3000</param-value>
	</context-param>
	<listener>
		<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
	</listener>

좋은 웹페이지 즐겨찾기