Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to create com.google.cloud.logging.LogEntry with both TextPayload and JsonPayload #1759

Open
snturk opened this issue Feb 3, 2025 · 0 comments
Assignees
Labels
api: logging Issues related to the googleapis/java-logging API.

Comments

@snturk
Copy link

snturk commented Feb 3, 2025

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

LogEntry logEntry =
LogEntry.newBuilder(logPayload.getPayload())
    .setLogName(GOOGLE_CLOUD_LOG_NAME)
    .setSeverity(severity)
    .setTimestamp(logPayload.getTimestamp())
    .build();
logging.write(Collections.singleton(logEntry));
@product-auto-label product-auto-label bot added the api: logging Issues related to the googleapis/java-logging API. label Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the googleapis/java-logging API.
Projects
None yet
Development

No branches or pull requests

2 participants