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

console logging is inadequate for a production server #1264

Closed
brandondoran opened this issue Jun 28, 2018 · 5 comments
Closed

console logging is inadequate for a production server #1264

brandondoran opened this issue Jun 28, 2018 · 5 comments

Comments

@brandondoran
Copy link

Apollo Server claims to be "production-ready" but I would not consider using console for logging as production quality. The project should provide the ability to use a custom logger such as bunyan, winston, pino, etc to allow for basic features, like log levels and formatting, that you need in a real production app. When logs have a well defined format, such as json, they can be sent to a kibana/splunk, etc for introspection

I'm using apollo-server in production now and most logs are taken care of in user code. But I would imagine in 2.0, with the apollo-datasource-rest, there will be many more scenarios where apollo-server itself will need to log, such as http error details, response times.

My specific use case is that I want to be able to use the same logger in apollo-server as I do in application code so that the format is the same and to allow trace or debug logs to be seen in dev but not clutter up production logs by using log levels instead of conditional code based on NODE_ENV like here. Maybe I want to temporarily see debug logs in production to troubleshoot and issue, which in a 12 Factor app, I should able to do but just changing log level config, not modifying code.

I'd be more than happy to help out here.

@evans
Copy link
Contributor

evans commented Jun 28, 2018

@brandondoran Thank you for bringing up the concern! Here are the docs for metrics/logging https://www.apollographql.com/docs/apollo-server/v2/features/metrics.html#Logging. If you would like to add more to those docs, that would be extremely valuable.

The next thing on my list is documenting the extensions api, which you can do things like: https://github.com/apollographql/apollo-server/blob/8914b135df9840051fe81cc9224b444cfc5b61ab/packages/apollo-server-core/src/logging.ts. Are you looking for more functionality than that? Adding more to extensions would also be a great contribution.

The rest data source is a relatively new portion of the stack, so we'll be adding tracing support soon after the 2.0 launch. If you're looking for something specific, we'd love to hear it!

@brandondoran
Copy link
Author

@evans Thanks for the links! I'm not running v2 yet so I haven't looked at this part of the docs in detail. Once I start getting my hands dirty with it, I'll keep in mind contributing to the docs if it seems lacking.

@shellscape
Copy link

I'm in agreement with the OP. Additionally, documentation on how to write an extension (let alone one without being forced into TypeScript) is non-existent. @evans we're fast approaching a year since you mentioned that the extensions need to be documented. This is a major hole in entire platform.

@ngbrown
Copy link

ngbrown commented Mar 29, 2019

I've been using a logging extension that I made which integrates with bunyan. Feel free to use it as as starting point your logger:

https://gist.github.com/ngbrown/b626c589b76d0f6ef6f9801a2faf6458

@shellscape
Copy link

I've secured apollo-log on npm and will be releasing a leveled logger for apollo-server in the coming weeks. Still mind boggling that this is a need, but alas.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants