You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 8, 2023. It is now read-only.
Hi,
I am not able to figure how to use pino-pretty so that I can save my log to a file as well as use teeToStdout option to get that on console in a prettified way when I am in development environment.
Here is my rotate-log config :
module.exports = {
filter(data) {
// logic can be added here to determine if the data should be logged
// refer to https://www.npmjs.com/package/@vrbo/pino-rotating-file
// Do not log if data do not contain http request
return !data.req;
},
output: {
path: "app.log", // name of file
options: {
path: `./logs/${dest}/app`, // path to write files to
size: "2M", // max file size
interval: "1d", // rotate daily
teeToStdout: process.env.NODE_ENV !== "production" // writes file content to stdout as well.
}
}
};
Here is my logger config :
const level = envConfig.ENV === ENVIRONMENTS.PRODUCTION ? LOG_LEVELS.INFO : LOG_LEVELS.DEBUG;
const prettyPrint = {
colorize: "true", // --colorize: add terminal color escape sequence to the output
levelFirst: true, // --levelFirst: display the log level name before the logged date and time
translateTime: "SYS:standard", // --translateTime: translate the epoch time to local system's TZ, in human readable format
ignore: "pid,hostname,module", // --ignore: ignore one or several keys
singleLine: true, // --singleLine: print each log message on a single line
messageFormat: "({module}) {msg}" // --messageFormat: format outpout for the message portion of the log
};
export const logger = pino(
{
name: "server",
level: level || LOG_LEVELS.DEBUG,
formatters: {
level(label) {
return { level: label };
}
},
prettyPrint: envConfig.ENV === ENVIRONMENTS.PRODUCTION ? false : prettyPrint
}
);
This command is being used in pipe to server start command in npm script : cross-env-shell NODE_ENV=development rotate-logs --config=$INIT_CWD/configs/app-log.config.js
What I am looking for is use this type of configuration but using this package :
Hi,
I am not able to figure how to use
pino-pretty
so that I can save my log to a file as well as useteeToStdout
option to get that on console in a prettified way when I am in development environment.Here is my rotate-log config :
Here is my logger config :
This command is being used in pipe to server start command in npm script :
cross-env-shell NODE_ENV=development rotate-logs --config=$INIT_CWD/configs/app-log.config.js
What I am looking for is use this type of configuration but using this package :
I have tried to implement this myself, but somehow I am not able to figure out. Can you please provide some inputs or help me with it.
Thanks in advance.
The text was updated successfully, but these errors were encountered: