Closed s1mrankaur closed 3 years ago
Hi @s1mrankaur, pino has no built in support for sampling a % of debug logs. You may be able to build your own hook or transport to do so by checking out the documentation.
If a lambda request contains the header x-correlation-trace-debug
with a value of true
, debug logging will be dynamically enabled for that request.
Is there any way to change log level based on environment variable?
@pjain11 You can use any options that pino
supports.
https://getpino.io/#/docs/api?id=options
// example
const logger = pino({ level: process.env.LOG_LEVEL });
@carbonrobot I saw the above but i'm not sure how to make it work with pino-lambda. I tried passing that option when initializing, something like below but does not work.
import Pino from 'pino-lambda'; const pinoLogger = Pino({ level: process.env.LOG_LEVEL });
For future readers: I'm using this in a typescript project, i was missing to install types for pino (npm i @types/pino). That fixes the issue.
We are able to add co-relationIds to our requests using this module.