[英]SpringBoot logback-spring.xml springprofile is not working
In my logback-spring.xml if I include logger level as INFO it is working fine but for other than INFO(WARN,ERROR) even application is not loading.After below log in console applicatiton booting is stopped forever. 在我的logback-spring.xml文件中,如果我将记录器级别作为INFO包括在内,则可以正常工作,但对于INFO(WARN,ERROR)而言,即使应用程序未加载,也无法加载。 This is the link we tried for this .Any help is appreciable. 这是我们为此尝试的链接 。任何帮助都是可以的。
Output in Console as log: 在控制台中作为日志输出:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.2.RELEASE)
logback-spring.xml 的logback-spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml" />
<appender name="consoleAppender" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}-%msg %n
</Pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>TRACE</level>
</filter>
</appender>
<appender name="minuteRollingFileAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>/usr/src/app/logs/test%d{yyyy-MM-dd_HH-mm}.log
</FileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{35}-%msg %n</Pattern>
</encoder>
</appender>
<springProfile name="dev,staging">
<root>
<level value="INFO" /><!--ERROR not working -->
<appender-ref ref="minuteRollingFileAppender" />
<appender-ref ref="consoleAppender" />
</root>
</springProfile>
</configuration>
The Spring-boot banner could be explicit included or excluded from the console. Spring-boot标语可以明确包含在控制台中,也可以从控制台中排除。 There are settings in some IDE's to do that. 在某些IDE中可以进行设置。
If you dont have any logs for log level different than INFO
you will only see the banner for application start. 如果没有与INFO
不同的日志级别的日志,则只会看到应用程序启动的标语。 It looks like the application does not start but thats just because there are no logs written. 看起来应用程序没有启动,但是那仅仅是因为没有写日志。
Excluding the banner in application.properties
: 不包括application.properties
的横幅:
spring.main.banner-mode=off
or in main
: 或main
:
SpringApplication app = new SpringApplication(SpringBootConsoleApplication.class);
app.setBannerMode(Banner.Mode.OFF);
app.run(args);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.