Closed brandondoran closed 6 years ago
@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!
@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.
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.
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
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.
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 introspectionI'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.