我使用gradle运行spring-webmvc项目,使用命令
./gradlew clean jettyRun
然而,每当我运行它时,我都会收到调试消息的垃圾邮件,例如(这只是一个例子)
16:21:13.507 [1407721353@qtp-1264231563-3] DEBUG org.springframework.web.servlet.view.BeanNameViewResolver - No matching bean found for view name 'page'
16:21:13.511 [1407721353@qtp-1264231563-3] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'freemarkerConfig'
16:21:13.514 [1407721353@qtp-1264231563-3] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'page'
16:21:13.515 [1407721353@qtp-1264231563-3] DEBUG freemarker.cache - TemplateLoader.findTemplateSource("page_en_US.ftl"): Not found
16:21:13.516 [1407721353@qtp-1264231563-3] DEBUG freemarker.cache - TemplateLoader.findTemplateSource("page_en.ftl"): Not found
16:21:13.517 [1407721353@qtp-1264231563-3] DEBUG freemarker.cache - TemplateLoader.findTemplateSource("page.ftl"): Not found
16:21:13.517 [1407721353@qtp-1264231563-3] DEBUG freemarker.cache - "page.ftl"("en_US", Cp1252, parsed) no source found.
任何人都知道如何通过所有这些消息让我不垃圾邮件?我想将日志级别设为WARN而不是DEBUG
我已经尝试推送application.properties
文件,其中警告级别在所有地方定义,如here所述,它没有帮助。
修改
我的build.gradle文件是
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'jetty'
apply plugin: 'war'
apply plugin: 'org.springframework.boot'
repositories {
mavenCentral()
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web:1.5.1.RELEASE") {
exclude module: "spring-boot-starter-tomcat"
}
compile group: 'org.springframework.boot', name: 'spring-boot-starter-jetty', version: '1.5.1.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: '1.5.1.RELEASE'
compile group: 'org.springframework', name: 'spring-webmvc', version: '4.3.6.RELEASE'
compile group: 'org.springframework', name: 'spring-context-support', version: '4.3.6.RELEASE'
compile group: 'org.springframework', name: 'spring-orm', version: '4.3.6.RELEASE'
compile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
compile group: 'org.freemarker', name: 'freemarker', version: '2.3.23'
compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.5'
compile group: 'org.hibernate', name: 'hibernate-core', version: '5.1.4.Final'
compile group: 'commons-validator', name: 'commons-validator', version: '1.5.1'
compile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '1.5.1.RELEASE'
}
task wrapper(type: Wrapper) {
gradleVersion = '2.2'
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.1.RELEASE")
}
}
请注意,虽然我已经在其中包含了bootstrap,但我没有使用它从命令行运行,
更不用说bootstrap日志消息看起来像这样
2017-02-21 16:53:11.256 INFO 6004 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0
2017-02-21 16:53:11.379 INFO 6004 --- [ main] application : Initializing Spring FrameworkServlet 'dispatcherServlet'
2017-02-21 16:53:11.379 INFO 6004 --- [ main] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2017-02-21 16:53:11.395 INFO 6004 --- [ main] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 16 ms
2017-02-21 16:53:11.415 INFO 6004 --- [ main] o.e.jetty.server.AbstractConnector : Started ServerConnector@418f890f{HTTP/1.1,[http/1.1]}{0.0.0.0:8888}
答案 0 :(得分:2)
在资源目录中添加logback.xml。确保你的类路径中有logback jar。
<强> logback.xml 强>
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- Log message format -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<!-- Setting the root level of logging to INFO -->
<root level="info">
<appender-ref ref="STDOUT" />
</root>
</configuration>