From 2ef073f6009783049a5feb8628e0797c7053319b Mon Sep 17 00:00:00 2001 From: sebright Date: Tue, 22 Jan 2019 09:56:50 -0800 Subject: [PATCH] adservice: Add "time" field to JSON log entries. (#129) The Log4j JsonLayout puts the log entry timestamp in a field named "instant" by default, but the Stackdriver Logging agent does not understand that field. The logging agent instead uses the time that it received the log entry, which is less accurate and has only second-level precision. This commit adds a key-value pair to the JsonLayout pattern that can be understood by the logging agent. It uses a "time" key as described in https://cloud.google.com/logging/docs/agent/configuration#timestamp-processing and formats the timestamp as described in the Protocol Buffer JSON mapping, https://developers.google.com/protocol-buffers/docs/proto3#json. Allowing the Stackdriver Logging agent to read the more accurate timestamps inserted by Log4j is especially important in the adservice, because the logs are correlated with traces, and it is important to see where each message was logged on the timeline of the trace. --- src/adservice/src/main/resources/log4j2.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/adservice/src/main/resources/log4j2.xml b/src/adservice/src/main/resources/log4j2.xml index 177c483..9d85f97 100644 --- a/src/adservice/src/main/resources/log4j2.xml +++ b/src/adservice/src/main/resources/log4j2.xml @@ -3,12 +3,14 @@ - + +