1
votes

We have a project that's configured with both Rails/Lograge. According to the documentation it seems that you simply include the gem. I'm wondering if it's possible to send additional information as a jsonPayload. All of our logging is being parsed only as textPayload.

https://github.com/googleapis/google-cloud-ruby/tree/master/stackdriver

https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry

We're also using AppEngine Flex so we have less control over the Fluentd implementation.

1

1 Answers

2
votes

It appears that the use of Ruby with Stackdriver logging is pretty well documented. See for example Stackdriver Logging Client Libraries.

Next we find reference documentation on the APIs here Module: Google::Cloud::Logging. And if we look at the Logger class, we find an example of writing a JSON payload to the log:

https://googleapis.github.io/google-cloud-ruby/docs/google-cloud-logging/latest/Google/Cloud/Logging/Logger.html

require "google/cloud/logging"

logging = Google::Cloud::Logging.new

resource = logging.resource "gae_app",
                            module_id: "1",
                            version_id: "20150925t173233"

logger = logging.logger "my_app_log", resource, env: :production

payload = { "stats" => { "a" => 8, "b" => 12.5} }
logger.info payload