Java 使用新的Google Cloud logging jar时,Google Cloud Platform Stackdriver中未显示日志
我遵循了上的文档,Java 使用新的Google Cloud logging jar时,Google Cloud Platform Stackdriver中未显示日志,java,google-cloud-platform,stackdriver,google-cloud-stackdriver,google-cloud-logging,Java,Google Cloud Platform,Stackdriver,Google Cloud Stackdriver,Google Cloud Logging,我遵循了上的文档,QuickstartSample.java是一个简单的API调用,用于将数据记录到Stackdriver public class QuickstartSample { public static void main(String... args) throws Exception { // Instantiates a client Logging logging = LoggingOptions.getDefaultInstance().getSer
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
version时,没有显示日志条目
它可以正确地与旧版本com.google.cloud:google cloud logging:1.2.1
Windows 7 64位
OpenJDK 8 64位
渐变版本3.0
(同样适用于maven 3.6.1,结果相同)
当我运行代码时,控制台中没有错误,在这两种情况下都会执行完整的程序,但只有在使用1.2.1版本时,日志才会发送到Stackdriver
我需要集成Stackdriver与我的项目,我想使用较新的版本。有人知道可能的原因吗?我遇到了一个类似的问题,我通过两种方式解决了这个问题:
我正在使用
com.google.cloud:google cloud logging:1.101.2
您是否可以向我们分享您正在使用的构建器,例如Gradle,您是否尝试过任何疑难解答工具,以了解日志信息的确切存储位置[1]。我建议您尽可能详细地分享您的通话方式。注意:com.google.cloud:googlecloudlogging的最新版本是1.88.0,请查看这个github文档()[1]我已经在问题中添加了详细信息。我尝试了1.88.0版本,但结果与1.87.0相同。我的项目密钥已经到位,它可以与旧jar正常工作。我没有使用过任何调试工具,你有什么建议可以帮助我吗?嗨,Divya,你有没有找到解决这个问题的方法,我也面临着同样的问题。
// 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();