How to call my created Listener instead of hiberante listener?

Viewed 55

I create my listener which should output the request data , but for some reason the context is output using hibernate listener and not my personal one that I created. How could I change this? OUTPUT:

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)

here I would like to change StatisticalLoggingSessionEventListener to my self-written listener

application.properties:

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.properties:

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

My main task is to output the start/end time and execution time of my query to the console, using hibernate and not using third-party libraries. I will be glad to advice and help!

0 Answers
Related