googleapis / googleapis/google-cloud-java

[java-logging] Impossible to create com.google.cloud.logging.LogEntry with both TextPayload and JsonPayload

オープン
#11,915 コメント 0 件 リアクション 0 件 担当者 1 名 @cindy-peng が担当を希望しています GitHub で見る
api: logging priority: p3
主要言語
Java
スター
2.1k
フォーク
1.2k
平均マージ
1日 23時間
マージ済み PR(30日)
154

説明

My program perfectly send logs to Logs Explorer with Google's `com.google.cloud.logging` library. However, when I want to set both textPayload and jsonPayload, I can't.

If just JsonPayload is set, then I'm unable to see log's message on preview. It just shows the URL that my Cloud Function works.

However, in com.google.logging.v2.LogEntry model, I can set both textPayload and jsonPayload. In this way I cannot send logs to server because of the `com.google.cloud.logging.Logging` instance's `write` method does not accept this type of LogEntry

#### Steps to reproduce

1. Write a simple LogEntry build statement with JsonPayload or TextPayload (cannot do both, that's the issue)
2. Run `logging.write(Collections.singleton(logEntry));` and see it display textpayload's content for preview on Logs Explorer but if you set JsonPayload, it just dont.

#### Code example

```java
LogEntry logEntry =
LogEntry.newBuilder(logPayload.getPayload())
.setLogName(GOOGLE_CLOUD_LOG_NAME)
.setSeverity(severity)
.setTimestamp(logPayload.getTimestamp())
.build();
logging.write(Collections.singleton(logEntry));
```

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。