Spring Boot App Engine log messages not showing
我有一个使用Java 8部署到App Engine标准环境的Spring Boot应用程序。我似乎无法在云控制台的日志查看器中显示日志消息。我确实有其他日志在工作,例如端点被命中。
logging.properties:
1 | .level = FINEST |
appengine-web.xml:
1 2 3 4 5 6 7 8 | <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> |
弹簧控制器:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 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请求,但没有登录。我正在附上我的日志的屏幕截图。
我终于找到了解决方案。您必须将以下内容添加到build.gradle文件中:
1 2 3 | configurations { compile.exclude group:"org.slf4j", module:"jul-to-slf4j" } |