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

[feat] Switch between apache-friendly and JSON output #156

Closed
2 tasks done
abetoots opened this issue Nov 24, 2022 · 2 comments
Closed
2 tasks done

[feat] Switch between apache-friendly and JSON output #156

abetoots opened this issue Nov 24, 2022 · 2 comments

Comments

@abetoots
Copy link

Describe the feature

This in relation to #132 . Currently, message always returns an apache-friendly string log. Can we add support for returning the message as JSON?

Ideally, if we are already using Axe, since it provides a normalized standard of logging, we could pass the JSON as metadata, like in here :
logger[level](message, metadata);

What I want as JSON would be this

cabin

Use case:
So I can send logs to JSON friendly centralized logging systems like DataDog or Papertrail.

Checklist

  • I have searched through GitHub issues for similar issues.
  • I have completely read through the README and documentation.
@titanism
Copy link
Contributor

@abetoots have you updated to the latest major versions of cabin and axe? we now have support for pre and post hooks. you could make an async post hook to send log data as json to datadog, papertrail, wherever.

https://github.com/cabinjs/cabin#send-logs-to-an-http-endpoint

https://github.com/cabinjs/axe/#send-logs-to-sentry

@titanism
Copy link
Contributor

@abetoots note that the cabin middleware calls the logger (axe) with the request parsed, so you could make a post hook to JSON.stringify or use a package such as fast-safe-stringify to send err, message, and meta to datadog

@abetoots we have added Datadog and Papertrail examples for you, see these below references:

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

No branches or pull requests

2 participants