본문 바로가기
Framework/Log4j

Default

by windrises 2008. 1. 21.

simple log4j

[WEB-INF/classes/log4j.properties]

#===================================================================#
#               this is root logger definition                      #
#===================================================================#      
log4j.rootLogger=ERROR, CONSOLE
log4j.logger.sfmi=DEBUG
log4j.logger.com.ibatis=DEBUG
log4j.logger.java.sql=DEBUG

#===================================================================#
#               this is logger definition for each category         #                                    
#===================================================================#
#log4j.category.jsp=debug, ROLLING_FILE_LOGGER
#log4j.category.service=debug, CONSOLE
#log4j.category.ejb=debug, FILE_LOGGER
#log4j.category.dao=debug, XML_FILE_LOGGER


#===================================================================#
#           appender definition                          #
#===================================================================#

#File Appender------------------------------------------------------
log4j.appender.FILE_LOGGER=org.apache.log4j.FileAppender
log4j.appender.FILE_LOGGER.File=c:/log/ejb/ejb.log
log4j.appender.FILE_LOGGER.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE_LOGGER.layout.ConversionPattern=="%d{dd MMM yyyy HH:mm:ss,SSS} %-5p %-17c{2} (%13F:%L) %3x - %m%n

#RollingFile Appender------------------------------------------------
log4j.appender.ROLLING_FILE_LOGGER=org.apache.log4j.RollingFileAppender
log4j.appender.ROLLING_FILE_LOGGER.File=c:/log/jsp/jsp.log
log4j.appender.ROLLING_FILE_LOGGER.MaxFileSize=100KB
log4j.appender.ROLLING_FILE_LOGGER.MaxBackupIndex=1
log4j.appender.ROLLING_FILE_LOGGER.layout=org.apache.log4j.PatternLayout
log4j.appender.ROLLING_FILE_LOGGER.layout.ConversionPattern=="%d{dd MMM yyyy HH:mm:ss,SSS} %-5p %-17c{2} (%13F:%L) %3x - %m%n

#XML File Appender----------------------------------------------------
log4j.appender.XML_FILE_LOGGER=org.apache.log4j.FileAppender
log4j.appender.XML_FILE_LOGGER.File=c:/log/dao/dao.xml
log4j.appender.XML_FILE_LOGGER.Append=false
log4j.appender.XML_FILE_LOGGER.layout=org.apache.log4j.xml.XMLLayout

#Console Appender-----------------------------------------------------
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
#log4j.appender.CONSOLE.layout.ConversionPattern=%-4r %-5p %37c %3x - %m%n
log4j.appender.CONSOLE.layout.ConversionPattern=%5p %-17c{1}:%L - %m%n


[USE]
private static final Log logger = LogFactory.getLog(ClassName.class);

logger.debug("~");

Log4j 1.2.8-