간단한 log4j 설정

5086 단어 log4j

 log4j.properties:

log4j.rootLogger=ERROR, logfile,console
log4j.logger.com.opensymphony.xwork2=error, logfile
log4j.logger.org.hibernate.cfg=ERROR,console,logfile
log4j.appender.logfile=org.apache.log4j.RollingFileAppender
log4j.appender.logfile.File=D\:\\markertlog\\log4j.log
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=[%-5p] %d{HH:mm:ss} [%c{1}] - %m%n

# 
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%-5p] %d{HH:mm:ss} [%c{1}] - %m%n 

 
 
 
A.java에서 호출하는 경우:
private transient final Log logger = LogFactory.getLog(A.class);
방법에서logger를 사용할 수 있습니다.error("..................");
 
 
 
 
 
log4j 간단한 설명:
###  ConsoleAppender( )     stout    ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender###   
log4j.appender.stdout.Target=System.out###  System.err
log4j.appender.stdout.Threshold=ALL#stout 
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout# 
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} %5p %c:%L - %m%n#  
#-X  : X  
#%p:  ,  DEBUG,INFO,WARN,ERROR,FATAL 
#%d:  ,  ISO8601, ,  :%d{yyy MMM dd HH:mm:ss,SSS}, :2002   10   18   22:10:28,921 
#%r:   log   
#%c:  ,  
#%t:   
#%l:  , %C.%M(%F:%L) , 、 ,  
#%x:   NDC %%:  "%"  
#%F:   
#%L:   
#%m:  ,  
#%n:    % 、 、 

###  FileAppender( )    file    ###
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=log4js.log### 
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n


###Appenders 
#org.apache.log4j.ConsoleAppender 
#org.apache.log4j.FileAppender 
#org.apache.log4j.DailyRollingFileAppender # 
#org.apache.log4j.RollingFileAppender# 
#org.apache.log4j.WriterAppender 

###Layouts
#org.apache.log4j.HTMLLayout 
#org.apache.log4j.PatternLayout 
#org.apache.log4j.SimpleLayout 
#org.apache.log4j.TTCCLayout

### set log levels - for more verbose logging change 'info' to 'debug' ###
#ALL < DEBUG < INFO <WARN < ERROR < FATAL < OFF 
log4j.rootLogger=ALL,stdout,file ## root ,   
# 
#log4j.logger.org.apache.struts2=off
#log4j.logger.org.springframework=warn
#log4j.logger.com.opensymphony.xwork2=warn
#log4j.logger.com.maneater=off

#log4j.logger.org.hibernate=info
#log4j.logger.org.hibernate=debug

### log HQL query parser activity
#log4j.logger.org.hibernate.hql.ast.AST=debug

### log just the SQL
#log4j.logger.org.hibernate.SQL=debug

### log JDBC bind parameters ###
#log4j.logger.org.hibernate.type=info
#log4j.logger.org.hibernate.type=debug

### log schema export/update ###
#log4j.logger.org.hibernate.tool.hbm2ddl=debug

### log HQL parse trees
#log4j.logger.org.hibernate.hql=debug

### log cache activity ###
#log4j.logger.org.hibernate.cache=debug

### log transaction activity
#log4j.logger.org.hibernate.transaction=debug

### log JDBC resource acquisition
#log4j.logger.org.hibernate.jdbc=debug

### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace

좋은 웹페이지 즐겨찾기