How to configure Log4j2 with Spring Boot

0

Please note the structure of my project and try to see where my log4j2.xml file is

Iconfiguredthisway;

Now look at line 13 of the log4j2.xml file

This line has the purpose that when the project does a database write it emits a SQL log in the eclipse consoles to inform that it hears an insert, however this is not what is happening, currently when I write information in the bank it shows nothing on the eclipse consoles. I'm using FramWorks Spring Boot, I do it in Spring MVC and it works normally, I'm thinking it might be an artifact problem or some configuration problem that I need to run in Spring Boot.

I know I can do this in the application.properties file, but my goal is to make the settings in log4j2

/////////////////////////////////////////////// //////////////////////

I've tried these attempts

I changed the artifacts of this

<!-- Logging -->
<log4j.version>2.6</log4j.version>
<jcl-over-slf4j.version>1.7.21</jcl-over-slf4j.version>

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-slf4j-impl</artifactId>
    <version>${log4j.version}</version>
</dependency>
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>${log4j.version}</version>
</dependency>
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>${log4j.version}</version>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>jcl-over-slf4j</artifactId>
    <version>${jcl-over-slf4j.version}</version>
</dependency>

For this;

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j2</artifactId>
        </dependency>

But it did not work.

Does anyone have a suggestion?

    
asked by anonymous 18.06.2017 / 15:09

1 answer

-1

From what I understood of your problem would be that you want to login hibernate.

Hibernate itself has a config for this, I found this post in stakoverflow that can help you link

Because if I'm not mistaken Hibernate has a property that you put to true and it logs the sql it uses.

And this link demonstrates another way to configure, link in it Myong boots the hibernate log level to INFO, have you tried it?

    
09.12.2017 / 20:56