弹簧靴&x2B;Groovy+;logback.groovy
我在我的Spring boot应用程序中混合了Groovy和Java。Rest控制器和数据访问是用Groovy编写的。配置主要使用Java 根据logback文档,如果类路径中有logback.groovy文件,那么应该在logback.xml之前选择它。然而,在我的案例中,只有logback.xml起作用 我正在以sprint启动应用程序的形式运行该应用程序 另外,值得注意的是,spring建议继承一些日志配置,如下所示弹簧靴&x2B;Groovy+;logback.groovy,groovy,spring-boot,logback,logback-groovy,Groovy,Spring Boot,Logback,Logback Groovy,我在我的Spring boot应用程序中混合了Groovy和Java。Rest控制器和数据访问是用Groovy编写的。配置主要使用Java 根据logback文档,如果类路径中有logback.groovy文件,那么应该在logback.xml之前选择它。然而,在我的案例中,只有logback.xml起作用 我正在以sprint启动应用程序的形式运行该应用程序 另外,值得注意的是,spring建议继承一些日志配置,如下所示 <configuration> <includ
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<logger name="org.springframework.web" level="DEBUG"/>
</configuration>
首先,我觉得你的
build.gradle
很奇怪:
- 您不包括
spring boot gradle插件
- 在
选项中,您可以定义作为Groovy插件默认值的设置,请参阅sourceset
- 注意:即使您混合使用java和groovy文件,您也不必将它们分开(如果您愿意,您可以这样做)。我通常将它们都保存在groovy目录中
- 在
部分中,您使用的是简单依赖项而不是(另请参见)依赖项
- 您有2个DB依赖项(H2和HSQL)
build.gradle
看起来像
buildscript {
ext {
springBootVersion = '1.5.1.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'groovy'
apply plugin: 'org.springframework.boot'
jar {
baseName = 'demo'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile 'org.springframework.boot:spring-boot-starter'
compile 'org.springframework.boot:spring-boot-starter-logging'
compile 'org.springframework.boot:spring-boot-starter-jdbc'
compile 'org.codehaus.groovy:groovy'
compile 'com.h2database:h2'
testCompile 'org.springframework.boot:spring-boot-starter-test'
testCompile 'org.codehaus.groovy.modules.http-builder:http-builder:0.5.0-RC2'
}
使用此配置logback.groovy
应该可以工作。对于特定的问题,只需发布您的logback.groovy
。但是正如您所注意到的,Groovy配置不是一个完整的公民。当您包括spring启动程序日志记录时
starter,您还可以使用logback spring.groovy
或logback spring.xml
扩展标准日志记录配置
对于完全控制,您必须使用XML配置,对于小项目,我停止使用logback.groovy
,而只是通过application.properties
中的一些设置配置日志启动器,请参阅
例如,application.properties
的一些设置,带有彩色列的日志(除了windows<10和IDEA中的windows<10以外的所有平台):
buildscript {
ext {
springBootVersion = '1.5.1.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'groovy'
apply plugin: 'org.springframework.boot'
jar {
baseName = 'demo'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile 'org.springframework.boot:spring-boot-starter'
compile 'org.springframework.boot:spring-boot-starter-logging'
compile 'org.springframework.boot:spring-boot-starter-jdbc'
compile 'org.codehaus.groovy:groovy'
compile 'com.h2database:h2'
testCompile 'org.springframework.boot:spring-boot-starter-test'
testCompile 'org.codehaus.groovy.modules.http-builder:http-builder:0.5.0-RC2'
}
logging.file = logs/jira.log
spring.output.ansi.enabled = DETECT
logging.level.root = INFO
logging.level.org.apache.http = WARN