Config P6Spy on Quarkus log result sql

237 Views Asked by At
  • I try config P6spy in my quarkus project successfully. But now I want it log result sql. How to P6spy log result sql? this is my code:
<dependency>
    <groupId>p6spy</groupId>
    <artifactId>p6spy</artifactId>
    <version>1.3</version>
</dependency>
  • application.properties

    quarkus.datasource.jdbc.driver=com.p6spy.engine.spy.P6SpyDriver

  • spy.properties

    module.log=com.p6spy.engine.logging.P6LogFactory realdriver=org.postgresql.Driver deregisterdrivers=false outagedetection=false filter=false autoflush=true #excludecategories=info,debug,batch,statement,commit,rollback,outage logfile=quarkus.log reloadproperties=false reloadpropertiesinterval=60 useprefix=false appender=com.p6spy.engine.logging.appender.FileLogger append=true log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout log4j.appender.STDOUT.layout.ConversionPattern=p6spy - %m%n log4j.logger.p6spy=INFO,STDOUT dateformat=yyyy-MM-dd hh:mm:ss a

  • this is quarkus.log :

    2022-12-28 03:37:06 PM|45|0|statement|select customer0_.id as id1_5_, customer0_.CREATE_TIME as create_t2_5_, customer0_.CREATE_TIME_UNIX as create_t3_5_, customer0_.UPDATE_TIME as update_t4_5_, customer0_.UPDATE_TIME_UNIX as update_t5_5_, customer0_.business_registration_number as business6_5_, customer0_.company as company7_5_, customer0_.country as country8_5_, customer0_.currency as currency9_5_, customer0_.description as descrip10_5_, customer0_.email as email11_5_, customer0_.mobile as mobile12_5_, customer0_.name as name13_5_, customer0_.status as status14_5_, customer0_.telephone as telepho15_5_ from customer customer0_ where customer0_.email=? limit ?|select customer0_.id as id1_5_, customer0_.CREATE_TIME as create_t2_5_, customer0_.CREATE_TIME_UNIX as create_t3_5_, customer0_.UPDATE_TIME as update_t4_5_, customer0_.UPDATE_TIME_UNIX as update_t5_5_, customer0_.business_registration_number as business6_5_, customer0_.company as company7_5_, customer0_.country as country8_5_, customer0_.currency as currency9_5_, customer0_.description as descrip10_5_, customer0_.email as email11_5_, customer0_.mobile as mobile12_5_, customer0_.name as name13_5_, customer0_.status as status14_5_, customer0_.telephone as telepho15_5_ from customer customer0_ where customer0_.email='[email protected]' limit 1 2022-12-28 03:37:06 PM|0|0|result|select customer0_.id as id1_5_, customer0_.CREATE_TIME as create_t2_5_, customer0_.CREATE_TIME_UNIX as create_t3_5_, customer0_.UPDATE_TIME as update_t4_5_, customer0_.UPDATE_TIME_UNIX as update_t5_5_, customer0_.business_registration_number as business6_5_, customer0_.company as company7_5_, customer0_.country as country8_5_, customer0_.currency as currency9_5_, customer0_.description as descrip10_5_, customer0_.email as email11_5_, customer0_.mobile as mobile12_5_, customer0_.name as name13_5_, customer0_.status as status14_5_, customer0_.telephone as telepho15_5_ from customer customer0_ where customer0_.email=? limit ?|select customer0_.id as id1_5_, customer0_.CREATE_TIME as create_t2_5_, customer0_.CREATE_TIME_UNIX as create_t3_5_, customer0_.UPDATE_TIME as update_t4_5_, customer0_.UPDATE_TIME_UNIX as update_t5_5_, customer0_.business_registration_number as business6_5_, customer0_.company as company7_5_, customer0_.country as country8_5_, customer0_.currency as currency9_5_, customer0_.description as descrip10_5_, customer0_.email as email11_5_, customer0_.mobile as mobile12_5_, customer0_.name as name13_5_, customer0_.status as status14_5_, customer0_.telephone as telepho15_5_ from customer customer0_ where customer0_.email='[email protected]' limit 1 2022-12-28 03:37:06 PM|52|0|commit||

Expect: it show result log

{
    "createTime": "2022-09-27 08:27:42:705",
    "createTimeUnix": 1664292462705,
    "id": 3787,
    "updateTime": "2022-09-27 08:27:42:705",
    "updateTimeUnix": 1664292462705,
    "company": "IMIP",
    "country": "VietNam",
    "currency": "KRW",
    "description": "",
    "email": "[email protected]",
    "name": "Tong Thi Hoa 14",
    "status": "Active"
}
1

There are 1 best solutions below

1
On

By default p6spy does not log results - please read about excludecategories parameter and default values:

#list of categories to exclude: error, info, batch, debug, statement,
#commit, rollback, result and resultset are valid values
# (default is info,debug,result,resultset,batch)
#excludecategories=info,debug,result,resultset,batch

in your case I believe that should be something like:

excludecategories=info,debug,result,batch

FYI. The only author of p6spy has abandoned project - I do not see any reason to use p6spy in new projects, moreover quarkus recommends to use opentracing