Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json log formatter ignores with_newline flag when jsonize is false #129

Open
daisy1754 opened this issue Mar 11, 2022 · 3 comments
Open

Comments

@daisy1754
Copy link

I wanted to change log format from json to hash, and tried below

logger.formatter.jsonize = false
logger.formatter.with_newline = true

Unfortunately this will produce log without newline because as shown in code below, with_newline flag is ignored if jsonize is false

return data unless @jsonize

I'm happy to send PR to change behaviour but technically this will be breaking behaviour change so wanted to first open the issue.

@tilfin
Copy link
Owner

tilfin commented Mar 13, 2022

When jsonize option is false, Ougai does not write a string to log files or STDOUT. it pass hash object to the logdevice.
ref) https://github.com/tilfin/ougai/wiki/Forward-logs-to-Fluentd

What log format do you want at last?

@daisy1754
Copy link
Author

Thanks for quick response. My end goal was to send log to GCP.

It seems that if you log string with json (like buyan formatter), GCP's log agent (which I think also is fluentd) just ignored my log entry. Problem is I cannot find log format the agent like, so I end up disabling jsonize.

With jsonize=false with default formatter, we at least was able to get log recognized, but multiple log entries were concatenated.

I endup writing custom formatter to make GCP (and datadog which we finally use for consuming log) happy, but if you have any suggestion that is appreciated.

@tilfin
Copy link
Owner

tilfin commented Mar 13, 2022

I wrote this a long time ago, but it may be helpful.
https://github.com/tilfin/fluent-plugin-bunyan-to-google-cloud-logging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants