mardi 20 septembre 2016

How to use log4j to do logging in ibatis + Spring for a specified class?

yes, I have already use log4j.

now in my ibatis.log file, I can get ibatis logs, but since my project is a large project composed of a lot of orm. Each time I get ibatis logs with 10 thousand lines. I really hope to read ibatis logs of a specified class not logs of the whole project.

So, my question is "How can I use log4j to do logging in ibatis + Spring for a specified class"

p.s. I have tried:

 log4j.logger.MYCLASS=TRACE

but it is not useful.

my log4j.properties looks like this:

log4j.rootLogger=debug,stdout,logfile


#log4j.appender.stdout=org.apache.log4j.ConsoleAppender
##log4j.appender.stdout.Target=System.err
#log4j.appender.stdout.layout=org.apache.log4j.SimpleLayout
log4j.logger.MYCLASS=TRACE


log4j.appender.logfile=org.apache.log4j.FileAppender
log4j.appender.logfile.File=/export/logs/ibatis.log
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %F %p %m%n


log4j.logger.com.ibatis=DEBUG
#log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=DEBUG
#log4j.logger.com.ibatis.common.jdbc.ScriptRunner=DEBUG
#log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG
#log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG
log4j.logger.java.sql.ResultSet = DEBUG




Aucun commentaire:

Enregistrer un commentaire