Hibernate does not use Log4J directly. This is why your messages get into the WebSphere SystemOut.log file.
Prior to version 3.2, sleep mode is used to write to the Jakarta Commons Logging as a logging facade. Starting with version 3.3 and higher, he switched to SLF4J (Simple Logging Facade for Java). Since Jakarta commons logging (JCL), SLF4J is simply a facade that is often associated with other logging systems such as Java Logging or, in this case, Log4J.
I understand that your application already uses Log4J. I also assume that you are using Hibernate 3.3 or newer.
First of all, you need to add SLF4J support to your project. You do this by adding these dependencies (using Ivy, Maven, or whatever you like):
slf4j-api.jar (Core SLF4J packages)
slf4j-log4j12.jar (binds SLF4J to Log4J)
Thus, when Hibernate logs a message, SLF4J will capture it and redirect it to Log4J.
Now, when it comes to your own application code, you have two approaches.
1: Keep your classes directly interacting with Log4J classes (namely Logger and LoggerFactory)
This way you keep your classes directly by reference to Log4J Logger, for example:
Logger logger = Logger.getLogger("com.foo"); // from package org.apache.log4j
So, in a word, Hibernate will use SLF4J -> Log4J, and you will use Log4J directly
2: The second approach is for your code to use SLF4J. This hasnโt changed so much, since you may only have to change one line of code in each of your classes that generates log messages:
Logger logger = LoggerFactory.getLogger("com.foo"); // from package org.slf4j
If you are using an older version of Hibernate (3.2 or older), you will have to trick it into not using Jakarta Commons Logging. First, you will have to clean up the JAR files that write the JAR files from your dependencies (manually or with an exception if you use any dependency manager). Then you will need to add the SLF4J shared port to your class path:
add jcl-over-slf4j-xyzjar (xyz is its version. For example, I use jcl-over-slf4j-1.6.1.jar ).
This jar has the exact classes and packages of the old commons-logging.jar, thereby effectively tricking all community-dependent applications for registering on SLF4J.