我有一个 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 请求,但看不到其中的日志记录。我附上了我的日志的屏幕截图。
最佳答案
我终于找到了解决办法。您必须将以下内容添加到 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/