New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[mergingObject] under custom property #1838
Comments
Can you include a full example showing errors that are swallowed? |
// logger
const loggerInstance = pino({
level: env.LOGGER_LOG_LEVEL,
timestamp: () => `,"timestamp":"${new Date(Date.now()).toISOString()}"`,
errorKey: 'error',
formatters: {
level: (label) => {
return { level: label.toUpperCase() };
},
log: (object) => {
return { logContext: object };
},
},
redact: ['req.headers', 'res.headers'],
});
const logger = loggerInstance.child(
{ kind: 'application' },
{ msgPrefix: '[APP] ' },
);
export const getLogger = (subKind: string) => logger.child({ subKind: subKind });
export const httpLogger = pinoHttp({
logger: loggerInstance.child({ kind: 'access' }),
msgPrefix: '[HTTP] ',
});
export const serverLogger = getLogger('server');
export const oidcLogger = getLogger('oidc');
export const trpcLogger = getLogger('trpc'); and for example doing serverLogger.error(new Error('first error'), 'first err');
serverLogger.error({ error: new Error('second error') }, 'second err');
---
[19:36:20.085] ERROR (51006): [APP] first err
kind: "application"
subKind: "server"
logContext: {
"error": {}
}
[19:36:20.086] ERROR (51006): [APP] second err
kind: "application"
subKind: "server"
logContext: {
"error": {}
} |
@mcollina any suggestion how can I put all logs under |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
Im struggling a bit with how I could nest my logs under the custom property in the log.
For example
logContext
as custom prop and a log with[mergingObject]
aslog.info({some: 'asd'}, 'abc')
I would Like it to be logged as
{pid: 1, hostname: 'asdsd', msg: 'abc', logContext: {some: 'asd'}}
How I can do that?
I've tried with
formatters.log
option asBut it breaks logging with errors (errors are swallowed).
The text was updated successfully, but these errors were encountered: