Closed spvn closed 2 years ago
Hello! Thank you for reaching out. I have tried out pino-http
myself with this package and it seems to have worked for me, logs are being written to CloudWatch Logs.
I tried two separate ways of setting the transport up with pino-http
, these are adaptations of the example code in its README:
const logger = require('pino-http')({
transport: {
target: '@serdnam/pino-cloudwatch-transport',
options: {
logGroupName: 'testing-pino-http',
logStreamName: 'test-stream',
awsRegion: process.env.AWS_REGION,
awsAccessKeyId: process.env.AWS_ACCESS_KEY_ID,
awsSecretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
}
}
})
function handle (req, res) {
logger(req, res)
req.log.info('something else')
res.end('hello world')
}
server.listen(3000)
const transport = pino.transport({
target: '@serdnam/pino-cloudwatch-transport',
options: {
logGroupName: 'testing-pino-http',
logStreamName: 'test-stream',
awsRegion: process.env.AWS_REGION,
awsAccessKeyId: process.env.AWS_ACCESS_KEY_ID,
awsSecretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
}
});
const parent = pino(transport)
const logger = require('pino-http')({
logger: parent
})
function handle (req, res) {
logger(req, res)
req.log.info('something else')
res.end('hello world')
}
server.listen(3000)
In both cases, logs were written to Cloudwatch Logs.
Hey thanks for the package. I've tried using it with pino-http but my logs don't seem to be getting transported to cloudwatch. Interestingly, the log group and log stream gets created by your package, but no logs get saved to that log stream...