R
R
Romanov19812020-10-17 23:31:07
Java
Romanov1981, 2020-10-17 23:31:07

Logger does not work well. How to fix?

Greetings dear forum users.

I have such a problem. Connected Logger

<!-- SLF4J LOG4J 12 Binding  -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.30</version>
        </dependency>

        
        <!-- Apache Log4j Core-->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.13.3</version>
        </dependency>


Created a settings file src\main\resources\log4j.properties
# Root logger option
log4j.rootLogger=INFO, file, stdout

log4j.logger.org.springframework.jdbc.core = TRACE
log4j.logger.org.springframework.jdbc.core.JdbcTemplate = TRACE

# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=D:\\Test\\logging.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n


Created a file for logs D:\\Test\\ logging.log

I have a question like this.
1. Why doesn't it output anything to the console at all?
2. Why is there not what I need in the log file? It is necessary for me that would show what JdbcTemplate makes requests.

Some data that is not interesting to me gets into the log file.

2020-10-18 07:08:32 INFO  RepositoryConfigurationDelegate:127 - Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-10-18 07:08:32 INFO  RepositoryConfigurationDelegate:187 - Finished Spring Data repository scanning in 128ms. Found 1 JPA repository interfaces.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question