FATAL 日志在 Google Cloud Kubernetes 上标记为 INFO
FATAL log is marked as INFO on Google Cloud Kubernetes
我有一个使用 Rails 2.5.1 的应用程序,它部署在 Google Cloud Kubernetes 上,但日志不工作 good.The FATAL 错误显示为 INFO 日志而不是 ERROR或关键。
额外上下文:
- Rails 5.2.1
- 此视图来自
Logs Viewer
- 我正在使用
RAILS_LOG_TO_STDOUT=true
。如果我删除它,则根本不会显示日志
谢谢。
[更新]
我更新了我的集群以使用最新的 Stackdriver API 但它仍然无法正常工作并且 Rails.logger.error
显示为 INFO。
查看文档 Cloud Logging for Legacy Logging and Monitoring section Best practices:
Severities: By default, logs written to the standard output are on the
INFO level and logs written to the standard error are on the ERROR
level. Structured logs can include a severity
field, which defines the
log's severity.
并且因为您正在使用 Ruby 生成的 RAILS_LOG_TO_STDOUT=true
日志事件,您可以看到严重性信息。
请记住,您应该迁移到 Kubernetes Engine Monitoring:
Warning: Legacy Logging and Monitoring support for Google Kubernetes
Engine is deprecated. If you are using Legacy Logging and Monitoring,
then you must migrate to Kubernetes Engine Monitoring before support
for Legacy Logging and Monitoring is removed.
迁移后最好return到这个"issue"。
编辑 查看文档 Writing Logs section Writing log entries,您可以在其中找到 Ruby:
的示例
Here is some sample code to write a single log entry to mylog. The
service, region, labels, and other content will change depending on
the entry and the application doing the writing.
require "google/cloud/logging"
logging = Google::Cloud::Logging.new project: "my-gcp-project-id"
entry = logging.entry entry.log_name = "my_application_log"
entry.payload = "Log message"
entry.severity = :NOTICE
entry.resource.type = "gae_app"
entry.resource.labels[:module_id] = "default"
entry.resource.labels[:version_id] = "20160101t163030"
logging.write_entries entry
我将日志格式更改为使用 JSON。
config.log_formatter = proc do |severity, datetime, progname, msg|
message = msg
message << " from #{progname}" if progname.present?
content = JSON.dump(timestamp: datetime.to_s, severity: severity, message: message)
content << "\n"
content
end
我有一个使用 Rails 2.5.1 的应用程序,它部署在 Google Cloud Kubernetes 上,但日志不工作 good.The FATAL 错误显示为 INFO 日志而不是 ERROR或关键。
额外上下文:
- Rails 5.2.1
- 此视图来自
Logs Viewer
- 我正在使用
RAILS_LOG_TO_STDOUT=true
。如果我删除它,则根本不会显示日志
谢谢。
[更新]
我更新了我的集群以使用最新的 Stackdriver API 但它仍然无法正常工作并且 Rails.logger.error
显示为 INFO。
查看文档 Cloud Logging for Legacy Logging and Monitoring section Best practices:
Severities: By default, logs written to the standard output are on the INFO level and logs written to the standard error are on the ERROR level. Structured logs can include a
severity
field, which defines the log's severity.
并且因为您正在使用 Ruby 生成的 RAILS_LOG_TO_STDOUT=true
日志事件,您可以看到严重性信息。
请记住,您应该迁移到 Kubernetes Engine Monitoring:
Warning: Legacy Logging and Monitoring support for Google Kubernetes Engine is deprecated. If you are using Legacy Logging and Monitoring, then you must migrate to Kubernetes Engine Monitoring before support for Legacy Logging and Monitoring is removed.
迁移后最好return到这个"issue"。
编辑 查看文档 Writing Logs section Writing log entries,您可以在其中找到 Ruby:
的示例Here is some sample code to write a single log entry to mylog. The service, region, labels, and other content will change depending on the entry and the application doing the writing.
require "google/cloud/logging"
logging = Google::Cloud::Logging.new project: "my-gcp-project-id"
entry = logging.entry entry.log_name = "my_application_log"
entry.payload = "Log message"
entry.severity = :NOTICE
entry.resource.type = "gae_app"
entry.resource.labels[:module_id] = "default"
entry.resource.labels[:version_id] = "20160101t163030"
logging.write_entries entry
我将日志格式更改为使用 JSON。
config.log_formatter = proc do |severity, datetime, progname, msg|
message = msg
message << " from #{progname}" if progname.present?
content = JSON.dump(timestamp: datetime.to_s, severity: severity, message: message)
content << "\n"
content
end