I just follow the doc: https://github.com/fastify/fastify/blob/master/docs/Getting-Started.md
start a server.js:
```
// Require the framework and instantiate it
const fastify = require('fastify')()
// Declare a route
fastify.get('/', function (request, reply) {
reply.send({ hello: 'world' })
})
// Run the server!
fastify.listen(3000, function (err) {
if (err) throw err
fastify.log.info(server listening on ${fastify.server.address().port})
})
but throw the error: **TypeError: Cannot read property 'info' of undefined**
Then add the option : {logger: true}
```
// Require the framework and instantiate it
const fastify = require('fastify')({logger: true})
// Declare a route
fastify.get('/', function (request, reply) {
reply.send({ hello: 'world' })
})
// Run the server!
fastify.listen(3000, function (err) {
if (err) throw err
fastify.log.info(`server listening on ${fastify.server.address().port}`)
})
the error still happen, i read the other docs, find the server.js below is work!
// Require the framework and instantiate it
const log = require('pino')({ level: 'info' })
const fastify = require('fastify')({logger: true})
// Declare a route
fastify.get('/', function (request, reply) {
request.log.info('here');
reply.send({ hello: 'world' })
})
// Run the server!
fastify.listen(3000, function (err) {
if (err) throw err
log.info(`server listening on ${fastify.server.address().port}`)
})
Is there something else i missed or there is something wrong with the docs?
The issue is that the documentation is tied to the latest on the master branch. The docs are referring to a breaking change merged by #436 that hasn't been published as a release yet. So you will need to reference fastify.logger for now.
cc: @delvedor @mcollina
we need to do a release.
3ks, i know @jsumners, @mcollina
Most helpful comment
The issue is that the documentation is tied to the latest on the master branch. The docs are referring to a breaking change merged by #436 that hasn't been published as a release yet. So you will need to reference
fastify.loggerfor now.cc: @delvedor @mcollina