1

So I have a project where I'm using Wildfly 10 and Hibernate 5.2.9 and I'm trying to log the hibernate stuff, such as Queries and so on, using Log4J2, but for some reason it's not working Log4J2 works when I log application stuff like log.info("SOMETHING")... I post here my log42j.xml file

<?xml version="1.0" encoding="UTF-8"?>
<Configuration xmlns="http://logging.apache.org/log4j/2.0/config">

<Appenders>
    <Appender type="FILE" name="FF" fileName="C:/logs/logfile.log">
        <Layout type="type" pattern="%-5p | %d{yyyy-MM-dd HH:mm:ss} | %C{2} 
(%F:%L) - %m%n"
    </Appender>
</Appenders>

<Loggers>
    <Logger name="my.java.package" level="DEBUG">
        <AppenderRef ref="FILE"></AppenderRef>
    </Logger>
    <Logger name="org.hibernate.type" level="TRACE">
        <AppenderRef ref="FILE"></AppenderRef>
    </Logger>
    <Logger name="org.hibernate.SQL" level="TRACE">
        <AppenderRef ref="FILE"></AppenderRef>
    </Logger>
    <Logger name="org.hibernate" level="TRACE">
        <AppenderRef ref="FILE"></AppenderRef>
    </Logger>

    <Root level="ALL">
        <AppenderRef ref="FILE"/>
    </Root>
</Loggers>

</Configuration>

Any thoughts of how can I solve this? Thanks!

2
  • possible duplicate: stackoverflow.com/questions/436276/… Commented May 31, 2017 at 14:13
  • I know it may seem like a duplicate, but I had already been through that post and others and I still got nowhere. That's why I posted my specific case =) Commented May 31, 2017 at 14:29

1 Answer 1

1

Since Hibernate is a module provided by the server it uses the servers logging configuration, not the configuration supplied in your deployment.

Really you wouldn't want Hibernate using your log configuration anyway. If you had multiple deployments, each having their own logging configuration there is no guarantee which configuration would win when configuring the logging.

Sign up to request clarification or add additional context in comments.

1 Comment

I wasn't seeing it that way, but I think you're right. It's best to just let Hibernate use the logging configuration of the server, since it would probably generate a lot of overhead in my log file mixed with the application logs which are the most important IMO. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.