简体   繁体   English

SpringBoot logback-spring.xml springprofile不起作用

[英]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.

相关问题 带有springProfile的Logback-spring.xml不能与多个配置文件一起使用 - Logback-spring.xml with springProfile not working with multiple profiles logback-spring.xml 配置springProfile时创建多个日志文件 - Logback-spring.xml creating multiple log files when configured with springProfile 在Springboot中无法读取logback-spring.xml中的属性 - Unable to read properties in logback-spring.xml in Springboot spring boot logback-spring.xml maxFileSize 不适用于 SizeAndTimeBasedRollingPolicy - spring boot logback-spring.xml maxFileSize not working with SizeAndTimeBasedRollingPolicy Spring Boot 忽略 logback-spring.xml - Spring Boot ignoring logback-spring.xml 使用logback-spring.xml时如何保持springboot默认日志 - how to keep springboot default log when using logback-spring.xml 以编程方式外部化logback-spring.xml - Externalize logback-spring.xml programmatically 无法将config文件夹中logback-spring.xml的属性覆盖到其他模块的logback-spring.xml - Cannot override properties of logback-spring.xml in config folder to other module's logback-spring.xml logback-spring.xml 级别配置中的“java.lang.IllegalStateException:无法从类路径初始化 Logback 日志记录:logback-spring.xml” - "java.lang.IllegalStateException: Could not initialize Logback logging from classpath:logback-spring.xml" in logback-spring.xml level configuration spring 引导命令行运行不使用 logback-spring.xml - spring boot command line run not using logback-spring.xml
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM