最简单的就是直接在jdbc db url加profileSQL=true,会在stderr输出sql执行情况,有毫秒日志。
Add 'logger' and 'profileSQL' to the jdbc url:
&logger=com.mysql.jdbc.log.Slf4JLogger&profileSQL=true
Then you will get the SQL statement below:
The default logger is:
com.mysql.jdbc.log.StandardLogger
Mysql does not know about your log4j properties.
From the docs, scroll to section Debugging/Profiling:
logger
The name of a class that implements "com.mysql.jdbc.log.Log" that will be used to log messages to. (default is "com.mysql.jdbc.log.StandardLogger", which logs to STDERR)
Default: com.mysql.jdbc.log.StandardLogger
So your mysql logs simply go to STDERR. If you want to log to a log4j defined destination you can implement com.mysql.jdbc.log.Log, forward to a log4j logger, and specify that implementation class in the connect URL.
0.00 avg. rating (0% score) - 0 votes