4

I am trying new version of Hibernate (I have used 3.x so far) and Hibernate switched to jboss-logging for whatever reason. This is something I could easily live with, but I like to keep my logs clean and readable and it inserts codes into log messages:

16 Feb 2013 19:25:08,352 INFO  [Version:37] - HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
16 Feb 2013 19:25:08,357 INFO  [Version:41] - HHH000412: Hibernate Core {4.1.9.Final}
16 Feb 2013 19:25:08,358 INFO  [Environment:239] - HHH000206: hibernate.properties not found
16 Feb 2013 19:25:08,359 INFO  [Environment:342] - HHH000021: Bytecode provider name : javassist

I am using log4j as logging library and my pattern is

log4j.appender.stdout.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss,SSS} %-5p [%c{1}:%L] - %m%n

and this suggests that the code is already part of the message that goes to log4j.

So is there any way to remove the codes from the log messages to have

16 Feb 2013 19:25:08,357 INFO  [Version:41] - Hibernate Core {4.1.9.Final}

I dont want to turn off hibernate logging completely, I just don't want the codes like HHH000412 in it.

František Hartman
  • 14,436
  • 2
  • 40
  • 60

1 Answers1

0

Refer to this to see the name of the log4j loggers used by the hibernate internally.

By configuring the log levels of these log4j loggers to different values , you can configure what the messages are being logged.

For instance , log4j.logger.org.hibernate=OFF to disable all the logging from hibernate . log4j.logger.org.hibernate=ERROR only will log the messages which log level is at least ERROR (i.e the INFO level log message will not be outputted)

Ken Chan
  • 84,777
  • 26
  • 143
  • 172