未显示

时间:2018-01-10 20:02:49

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

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

logging.properties:

.level = FINEST

应用服务引擎-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";
    }
}

当我在本地运行时,登录到控制台的工作完全正常。我只是无法在Web控制台中看到日志。我可以看到GET请求,但没有登录。我附上了我的日志的截图。

Cloud Log

1 个答案:

答案 0 :(得分:2)

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

import cmath

def quad(a,b,c):
   r = (b ** 2 - 4 * a * c)
   res1 = ((-b) + cmath.sqrt(r))/2
   res2 = ((-b) - cmath.sqrt(r))/2
   print("Solution 1: " + res1 + "Solution 2: " + res2)

nums = input()
param = nums.split()
p1 = float(param[0])
p2 = float(param[1])
p3 = float(param[2])
quad(p1,p2,p3)