[英]Google App Engine - log messages not visible
I have a Spring boot application deployed to GCP App Engine with logback as a logging framework. 我将Spring Boot应用程序部署到GCP App Engine,并将logback作为日志记录框架。 The problem which I am facing is that I can not find the logger messages which I put into my code.
我面临的问题是找不到在代码中放入的记录器消息。 I found a similar post: Google App Engine - Can not find my logging messages .
我发现了类似的帖子: Google App Engine-找不到我的日志消息 。 But it is pretty much older and the solutions are not working anymore.
但是它已经很老了,解决方案不再起作用。 On this post, it is mentioned to set the logger level manually.
在这篇文章中,提到了手动设置记录器级别。 On a similar line, I used
logging.properties
file to set the level as INFO. 在类似的行上,我使用
logging.properties
文件将级别设置为INFO。 But still, it was of no use. 但这仍然没有用。
I thought the issue might be with the file permission on the App Engine. 我认为问题可能出在App Engine上的文件许可权上。 So, I specified the log file location at
/tmp
having full read-write permissions. 因此,我在
/tmp
处指定了具有完全读写权限的日志文件位置。 It did not work. 这没用。 If there are any exception scenarios then stack traces are visible on Stackdriver Logging.
如果有任何异常情况,则堆栈跟踪在Stackdriver Logging中可见。 Please suggest.
请提出建议。
Here is how I managed to make the logs appear in Stackdriver under java.log
. 这是我设法使日志显示在
java.log
下的java.log
。
I created a file myApp/src/main/resources/logback.xml
and added this configuration: 我创建了文件
myApp/src/main/resources/logback.xml
并添加了以下配置:
<configuration>
<appender name="STDOUT" class="com.google.cloud.logging.logback.LoggingAppender">
</appender>
<root level="info">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
I also added the dependency in the file myApp/pom.xml
: 我还在文件
myApp/pom.xml
添加了依赖项:
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-logging-logback</artifactId>
<version>0.80.0-alpha</version>
</dependency>
<!-- other dependencies -->
</dependencies>
Then in my main.java
I did logger.info("my info log")
and logger.error("my error log")
and the logs appeared in Stackdriver after a few seconds of accessing my web app. 然后,在
main.java
我做了logger.info("my info log")
和logger.error("my error log")
,访问我的Web应用几秒钟后,这些日志出现在Stackdriver中。
I took the sample code from the GoogleCloudPlatform/getting-started-java repository to deploy my app. 我从GoogleCloudPlatform / getting-started-java存储库中获取了示例代码,以部署我的应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.