简体   繁体   中英

How to change the log level of AWS Lambdas(NodeJS) at runtime?

we use pino logger and it looks like this:

import pino from 'pino-lambda';


const logger = pino({
    name: 'ac',
    level: process.env.STAGE == 'prod' ? 'info' : 'debug',
    redact: ['password', ]
});

export default logger;

How to change the log level of our AWS Lambdas(NodeJS) at runtime?

 class CodelabsLogFormatter implements ILogFormatter { format(data: LogData): string { return `[employee-service]:[${data.level}] ${JSON.stringify(data)}`; } } const destination = CodelabsLogFormatter({ formatter: new KrishLogFormatter(), }); export const logger = pino( {level: process.env.LOG_LEVEL || 'info'}, destination );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM