我创建了应该输出请求数据的侦听器,但是由于某些原因,上下文是使用hibernate侦听器输出的,而不是我创建的个人侦听器。我怎样才能改变这个?输出:
11:20 15:18:04.868 [main] [INFO] [org.hibernate.engine.internal.StatisticalLoggingSessionEventListener] - Session Metrics {
0 nanoseconds spent acquiring 0 JDBC connections;
0 nanoseconds spent releasing 0 JDBC connections;
0 nanoseconds spent preparing 0 JDBC statements;
0 nanoseconds spent executing 0 JDBC statements;
0 nanoseconds spent executing 0 JDBC batches;
0 nanoseconds spent performing 0 L2C puts;
0 nanoseconds spent performing 0 L2C hits;
0 nanoseconds spent performing 0 L2C misses;
0 nanoseconds spent executing 0 flushes (flushing a total of 0 entities and 0 collections);
0 nanoseconds spent executing 0 partial-flushes (flushing a total of 0 entities and 0 collections)
这里我想把statisticalloggingsessioneventlistener改成我自己写的listener
应用程序属性:
spring.profiles.active=@spring.profiles.active@
server.port=5050
spring.datasource.url=jdbc:postgresql://localhost:5432/baida
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.username=postgres
spring.datasource.password=root
logging.config = src/main/resources/log4j.properties
spring.jpa.properties.hibernate.generate_statistics=true
logging.level.net.proselyte.springbootdemo.MyLogger=debug
log4j.属性:
name=PropertiesConfig
appenders = console
# logging.level.org.hibernate.engine.internal.StatisticalLoggingSessionEventListener=off
appender.console.type = Console
appender.console.name = ConsoleAppender
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %d{MM:dd HH:mm:ss.SSS} [%t] [%level] [%logger{36}] - %msg%n
rootLogger.level = INFO
rootLogger.appenderRefs = stdout
rootLogger.appenderRef.stdout.ref = ConsoleAppender
# batch processing
spring.jpa.properties.hibernate.jdbc.batch_size=10
spring.jpa.properties.hibernate.order_inserts=true
spring.jpa.properties.hibernate.order_updates=true
spring.jpa.properties.hibernate.jdbc.batch_versioned_data=true
我的主要任务是使用hibernate而不是第三方库,将查询的开始/结束时间和执行时间输出到控制台。我很乐意提供建议和帮助!
暂无答案!
目前还没有任何答案,快来回答吧!