먼저 log4.properties 파일...
저장 위치는 WEB-INF/classes/log4j.properties
저~ 아래 jar 파일은 WEB-INF/lib/
# Log4j Setting file
log4j.rootLogger=INFO, console
log4j.rootLogger=INFO, console
# Daily file log
log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender
#log4j.appender.logfile.File=G:/Apache_Tomcat/webapps/MusicalServer/MusicalServer.log
#log4j.appender.logfile.File=${catalina.home}/logs/musical.log
log4j.appender.logfile.File=/home/scuser/public_html/MusicalServer/Musical.log
log4j.appender.logfile.DatePattern='.'yyyy-MM-dd
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=[%d{HH:mm:ss}][%-5p](%F:%L) - %m%n
log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender
#log4j.appender.logfile.File=G:/Apache_Tomcat/webapps/MusicalServer/MusicalServer.log
#log4j.appender.logfile.File=${catalina.home}/logs/musical.log
log4j.appender.logfile.File=/home/scuser/public_html/MusicalServer/Musical.log
log4j.appender.logfile.DatePattern='.'yyyy-MM-dd
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=[%d{HH:mm:ss}][%-5p](%F:%L) - %m%n
# Console log
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%-5p %l - %m%n
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%-5p %l - %m%n
# log level and appender
log4j.logger.ticketBuy=INFO, logfile
log4j.logger.errorPurchase=INFO, logfile
log4j.logger.cancelPurchase=INFO, logfile
log4j.logger.ticketBuyResult=INFO, logfile
log4j.logger.ticketBuy=INFO, logfile
log4j.logger.errorPurchase=INFO, logfile
log4j.logger.cancelPurchase=INFO, logfile
log4j.logger.ticketBuyResult=INFO, logfile
jsp소스에선
Logger logger = Logger.getLogger("cancel_purchae.jsp");
logger.info("CancelPurchase : " + date.toString() + " mobile=" + mobile + " imgIdx=" + imgIdx + " CharacterCode=" + cCode);
간단히 저런 형식으로...
설정 파일을 많이 다뤄 본적이 없어서 로그를 파일로 남기는거 찾는데 고생한 기억이 ㅠㅠ
첨부된 파일은 log4j 라이브러리 파일
댓글 없음:
댓글 쓰기