![](/img/trans.png)
[英]Need help to bulk download logs from Google Cloud Platform - Cloud Logging
[英]Logs not showing in Google Cloud Platform Stackdriver when using new Google Cloud logging jar
我遵循有关Java 日志记录库的文档, QuickstartSample.java
是一个简单的 API 调用,用于将数据记录到 Stackdriver。
public class QuickstartSample {
public static void main(String... args) throws Exception {
// Instantiates a client
Logging logging = LoggingOptions.getDefaultInstance().getService();
// The name of the log to write to
String logName = "test-log";
// The data to write to the log
String text = "Hello, world!";
LogEntry entry = LogEntry.newBuilder(StringPayload.of(text))
.setSeverity(Severity.ERROR)
.setLogName(logName)
.setResource(MonitoredResource.newBuilder("global").build())
.build();
logging.write(Collections.singleton(entry));
System.out.printf("Logged: %s%n", text);
}
}
当我使用com.google.cloud:google-cloud-logging:1.87.0
版本时,没有显示日志条目。
它适用于旧版本com.google.cloud:google-cloud-logging:1.2.1
视窗 7 64 位
OpenJDK 8 64 位
Gradle 3.0 版(还有 maven 3.6.1,结果相同)
运行代码时控制台没有错误,两种情况下都执行完整的程序,但只有在使用 1.2.1 版本时才会将日志发送到 Stackdriver。
我需要将 Stackdriver 与我的项目集成,并且我想使用较新的版本。 有谁知道这可能的原因?
我遇到了类似的问题,我让它以两种方式工作:
// Writes the log entry synchronously
logging.setWriteSynchronicity(Synchronicity.SYNC);
logging.write(Collections.singleton(entry));
// Writes the log entry asynchronously
logging.write(Collections.singleton(entry));
logging.flush();
我正在使用com.google.cloud:google-cloud-logging:1.101.2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.