How to configure Log4j2 with Spring Boot

Asked

Viewed 383 times

0

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

inserir a descrição da imagem aqui

I set it up that way;

inserir a descrição da imagem aqui

Now note line 13 of log4j2.xml file

This line has the goal that when the project writes to a database it will send an SQL log to the eclipse consoles to inform that it hears an entry, but that’s not what’s happening, currently when I record information on the bank it shows nothing on the eclipse consoles. I am using Framworks Spring Boot, I do in Spring MVC and work normally, I’m thinking it may be artifact problem or some configuration problem I need to perform in Spring Boot.

I know I can perform this setting in the file application properties , but my goal is to carry out the settings in log4j2

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

I’ve tried these attempts

I switched the artifacts on this one

<!-- 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 that;

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

But it did not resolve.

Someone has a suggestion?

  • Someone can help me?

1 answer

-1

From what I understand your problem would be that you want to log in.

Hibernate himself has a config for this, I found this post on stakoverflow that can help you https://stackoverflow.com/questions/2536829/hibernate-show-real-sql

Because if I’m not mistaken Hibernate has a Property that you put to true and it log the sql that it uses.

And this link demonstrates another way to set up, https://www.mkyong.com/hibernate/how-to-display-hibernate-sql-parameter-values-log4j/ in it Myong puts the Hibernate log level for INFO, you already tried it?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.