I'm trying to set up sending my application logs to Google Cloud Logging, but no matter what I try, the logs are not visible in the Log Viewer.
I tried:
- using the Java Logging Logback appender directly, following all of the steps in the documentation, setting different combinations of parameters
- using Spring Cloud GCP, again following all of the tutorials and trying different configurations
- using the CLI to write log entries, using the examples from the docs
- using the API explorer to write log entries, providing all of the required fields
The Log ingestion tab shows that the data is actually ingested and I am able to retrieve the entries using gcloud logging read
or using the API explorer.
Unfortunately, the logs are not showing up in the viewer, which greets me with
[..] You do not have any logs in your project right now.
The logging API is, of course, enabled (I guess I wouldn't be able to get the CLI/API explorer to work without it).
Any clues what's wrong? Can it be that my logging entries have invalid format or are missing some key bit of information?
Attaching a couple of log entries, just in case. First was created by the API, second one was sent from the app:
insertId: 1mty0nhg3b7x2xx
logName: projects/my-project/logs/test.log
receiveTimestamp: '2020-05-25T11:18:57.565490347Z'
resource:
labels:
project_id: my-project
type: global
severity: INFO
textPayload: It works!
timestamp: '2020-05-25T11:18:57.565490347Z'
insertId: cs0e1zg1qqxxx6
labels:
levelName: INFO
levelValue: '20000'
loggerName: org.springframework.web.servlet.DispatcherServlet
logName: projects/my-project/logs/spring.log
receiveTimestamp: '2020-05-24T16:37:47.275614395Z'
resource:
labels:
project_id: my-project
type: global
severity: INFO
textPayload: Completed initialization in 17 ms
timestamp: '2020-05-24T16:37:47.234Z'
EDIT: I found a temporary workaround. I created a second project, wrote a short lambda that logs a message, and was able to see the logs for the lambda in that project. When I switched to the new "preview" mode, and changed project to the original one, I can now see the logs. However, when I switch back to "classic" mode, it still says that there are no logs in the project.