I have a Spring Boot application that I am deploying to an App Engine standard environment using Java 8. I cannot seem to get log messages to show in the log viewer in my cloud console. I do have other logs working such as the endpoint being hit.
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>
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";
}
}
Logging to the console works perfectly fine when I run locally. I just can't see the logs in the web console. I can see the GET request but not the logging in it. I am attaching a screenshot of my log.
I was finally able to find a solution. You must add the following to the build.gradle file: