简体   繁体   English

在 GCP 中更改 Stackdriver Logging 日志的标头

[英]Changing the header of Stackdriver Logging logs in GCP

I am currently working on a GAS project with a lot of consol.log , but it's a project which will be deployed.我目前正在处理一个包含大量consol.log的 GAS 项目,但这是一个将被部署的项目。

Is it possible to have a userName or a userMail in the header of a GCP Stakdriver Logging log entry, next to the date and time?在 GCP Stakdriver Logging 日志条目的标题中,日期和时间旁边是否可以包含userNameuserMail

Here's the part I'm referring to:这是我所指的部分:

1

Thank you for your answers.谢谢您的回答。

You can't directly modify the header (it will always contain only the timestamp of the log), but you can add custom fields next to it.您不能直接修改标题(它始终只包含日志的时间戳),但您可以在其旁边添加自定义字段

First, you have to include the fields you want to display ( userName and userMail ) in your entry log.首先,您必须在条目日志中包含要显示的字段( userNameuserMail )。 You can include that in the jsonPayload field of the log entry (see the docs of Structured Logging ).您可以将其包含在日志条目的jsonPayload字段中(请参阅Structured Logging的文档)。 Once done, assuming that your fields are jsonPayload.userName and jsonPayload.userMail , you can do the following on Stackdriver Logging page in the Google Console :完成后,假设您的字段是jsonPayload.userNamejsonPayload.userMail ,您可以在 Google Console 的jsonPayload.userMail Logging 页面上执行以下操作:

  • click on View options (top-right corner, near Download logs )点击查看选项(右上角,靠近下载日志
  • choose Modify custom fields选择修改自定义字段
  • add your fields as custom fields : jsonPayload.userName,jsonPayload.userMail将您的字段添加为自定义字段: jsonPayload.userName,jsonPayload.userMail

Once refreshed, the web page should display your fields at the right of the timestamp.刷新后,网页应在时间戳右侧显示您的字段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM