google-app-engine - Spring Boot App Engine 日志消息未显示

标签 google-app-engine spring-boot logging

我有一个 Spring Boot 应用程序,正在使用 Java 8 部署到 App Engine 标准环境。我似乎无法在云控制台的日志查看器中显示日志消息。我确实有其他日志在工作,例如端点被击中。

日志记录属性:

.level = FINEST

appengine-web.xml:

<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
    <threadsafe>true</threadsafe>
    <runtime>java8</runtime>
    <service>logging-service</service>

    <system-properties>
        <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
    </system-properties>
</appengine-web-app>

Spring Controller :

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.logging.Level;
import java.util.logging.Logger;

import static org.springframework.web.bind.annotation.RequestMethod.GET;

@RestController
@RequestMapping("/log")
public class LogSubscription {

    private static final Logger log = Logger.getLogger(LogSubscription.class.getName());

    @RequestMapping(method = GET)
    public String logSomething() {
        log.log(Level.INFO, "Should see this in the console");
        log.log(Level.SEVERE, "This is severe");
        log.info("Normal Log Message");

        return "Should log successfully";
    }
}

当我在本地运行时,登录到控制台工作得非常好。我只是在网络控制台中看不到日志。我可以看到 GET 请求,但看不到其中的日志记录。我附上了我的日志的屏幕截图。

Cloud Log

最佳答案

我终于找到了解决办法。您必须将以下内容添加到 build.gradle 文件中:

configurations {
    compile.exclude group: "org.slf4j", module: "jul-to-slf4j"
}

关于google-app-engine - Spring Boot App Engine 日志消息未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48195200/

相关文章:

java - 是否可以在 GAE 上使用 2 路电子邮件中继?

java - 为 Spring Boot 微服务创建 pojo

logging - 如何制定适当的策略来选择日志记录级别?

python - mrjob:在 EMR 上设置日志记录

.net - 通用ILogger,或者通过Serilog,添加logging属性

mysql - 将 MySQL 与 dev_appserver (Google App Engine) 和 Google SQL 服务一起使用

java - Dev App Server 不支持 App Engine 柔性环境应用程序

python - 在 WTForms 中填充 GAE 数据存储键值

spring - 使用aspectj在Spring Boot中重试死锁事务

java - 如何从外部 Maven 依赖项禁用 Log4j 配置?