【问题标题】:Spring Boot App Engine log messages not showingSpring Boot App Engine 日志消息未显示
【发布时间】:2018-01-10 20:02:49
【问题描述】:

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

logging.properties:

.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>

弹簧控制器:

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";
    }
}

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

【问题讨论】:

    标签: google-app-engine spring-boot logging


    【解决方案1】:

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

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

    【讨论】:

    • 这正是他们推荐的here
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-17
    • 1970-01-01
    • 1970-01-01
    • 2018-06-05
    • 2020-08-08
    • 1970-01-01
    • 2011-08-10
    相关资源
    最近更新 更多