Nikola Mihajlović
Nikola Mihajlović

Reputation: 2465

How to enhance log entries for standard environment?

I have a Java application running on Google App Engine standard environment.

I am able to log from it (using JUL). In standard environment, all the application log lines from a single web request are grouped into a single entry in the request_log. Everything runs great

However, now I have a requirement to add custom labels to a log entry for a request. For example, what is user ID associated with it.

Stackdriver documentation (https://cloud.google.com/logging/docs/setup/java) gives example how to "enhance" log entries with custom labels. However, it appears that the page does not apply to standard environment.

Is it possible to add labels (or any information associated with the log entry other than app log lines) to a log entry in request_log and how? If not, what are the alternatives?

Upvotes: 0

Views: 820

Answers (1)

Alex
Alex

Reputation: 76

The log enhancer would allow you to add a custom labels although it would be hard coded as this function (enhanceLogEntry(LogEntry.Builder logEntry)) is called at the end of the request when the log is being populated. Supplying a value from the request to appear in the request_log made by the application would not be possible.

I do not see how it would be limited to the flexible environment, you should be able to do it from the standard environment as far as I can tell.

Alternatively, I believe the best path would be to write your own logs entries by using the Stackdriver Logging Client Libraries within your request code.

Upvotes: 0

Related Questions