How to configure Lo4j in a Spring Boot project

0

The purpose of configuring log4j is to see the selects logs that Hibernate does on the eclipse consoles.

I have already set up Log4j in Spring MVC, but when I went to do the same procedure in Spring Boot did not work.

I did as follows;

First put the log4j.xml file in the src / main / resources package

See how the file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<Configuration status="WARN">
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %logger{36}: %msg%n" />
        </Console>
    </Appenders>

    <Loggers>

        <Logger name="org.hibernate.SQL" level="debug"/>

        <Root level="info">
            <AppenderRef ref="Console" />
        </Root>
    </Loggers>
</Configuration>

As it did not work I thought it would have been because of the lack of libraries, so I added these lines of code in pom.xml

<dependency>
   <groupId>org.apache.logging.log4j</groupId>
   <artifactId>log4j-api</artifactId>
   <version>2.5</version>
</dependency>
<dependency>
   <groupId>org.apache.logging.log4j</groupId>
   <artifactId>log4j-core</artifactId>
   <version>2.5</version>
</dependency>
<dependency>
   <groupId>org.apache.logging.log4j</groupId>
   <artifactId>log4j-jcl</artifactId>
   <version>2.5</version>
</dependency>

But it still did not work.

Having the first configuration problems you can find this tutorial below

Click here

I accept suggestions.

    
asked by anonymous 10.02.2017 / 16:08

1 answer

1

You need to add the following setting in application.properties :

spring.jpa.properties.hibernate.show_sql=true
    
10.02.2017 / 16:17