我创建了一个log4j.properties
文件弹簧启动应用程序,我已经把它的资源文件夹中的文件application.properties
,在这个文件中我有这样一行:logging.config=log4j.properties
这表明名称我的log4j的属性文件,但是当我运行我的应用程序我得到我的控制台上的错误:放在哪里log4j.properties文件中
Logging system failed to initialize using configuration from 'log4j.properties'
java.io.FileNotFoundException: C:\Users\***\Desktop\CapRecrute\log4j.properties (The system cannot find the file specified)
所以我试图logging.config
属性更改为src\\main\\resources\\log4j.properties
,然后我得到了另一个错误:
java.lang.IllegalStateException: Could not initialize Logback logging from src\main\resources\log4j.properties ... Caused by: ch.qos.logback.core.LogbackException: Unexpected filename extension of file [file:/C:/Users/Aimad%20MAJDOU/Desktop/CapRecrute/src/main/resources/log4j.properties]. Should be either .groovy or .xml
在我的POM文件我有这样的:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
我该如何解决这个问题?
你有没有读过这个:http://docs.spring.io/spring-boot/docs/current/reference/html/howto-logging.html – cjstehno