【问题标题】:Print only application logs仅打印应用程序日志
【发布时间】:2019-04-17 00:24:11
【问题描述】:

我想打印我的 Spring Boot 应用程序日志,但我想在 INFO 中打印我的应用程序日志。它正在编写从服务器启动到停止的所有内容。

我想在我的应用程序中写入 INFO 中的日志。

如何在 Spring Boot 中做到这一点?

【问题讨论】:

标签: spring spring-mvc spring-boot logging


【解决方案1】:

通过在应用程序构建器中调用 .logStartupInfo(false) 来禁用启动日志消息。

应该是这样的:

new SpringApplicationBuilder(ServiceConfiguration.class)
.logStartupInfo(false)
.run(args);

请参阅此link 以获得更清晰的信息。

在 src/main/resources 中添加 logback.xml,内容应该是:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{dd-MM-yyyy HH:mm:ss.SSS} %magenta([%thread]) %highlight(%-5level) %logger{36}.%M - %msg%n</pattern>
        </encoder>
    </appender>
    <root level="off">
        <appender-ref ref="STDOUT" />
    </root>
</configuration>

更多信息请查看link

【讨论】:

  • 在哪里写这个??
  • 在有@SpringBootApplication 并且有你的main方法的类中
  • 请分享您的 application.properties 文件
  • spring.data.mongodb.host=localhost spring.data.mongodb.database=oauthserver spring.data.mongodb.port=27017 spring.data.mongodb.uri=mongodb://localhost/oauthserver spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration server.servlet.context-path=/otp logging.path=/mnt/vol1/anchor/logs server.tomcat.accesslog.enabled=false 类似这个
  • 在 application.properties 文件中添加“logging.level.org.springframework.web: FATAL”。如果这不起作用,我想看看你的日志
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-05-23
  • 1970-01-01
  • 2019-03-18
  • 2019-08-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多