Skip to content
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

Not displaying trace logs despite minimum trace level #455

Open
tjakubo opened this issue Sep 6, 2023 · 4 comments
Open

Not displaying trace logs despite minimum trace level #455

tjakubo opened this issue Sep 6, 2023 · 4 comments

Comments

@tjakubo
Copy link

tjakubo commented Sep 6, 2023

This MWE

const pino = require('pino');

const transport = pino.transport({
  targets: [
    {
      level: 'trace',
      target: 'pino-pretty',
      options: {},
    },
  ],
});

const log = pino({}, transport);

console.log('console.log');
log.info('pino.info');
log.trace('pino.trace');

Only outputs two lines instead of expected three. Is it some misconfiguration issue, why doesn't it also show the trace log?
The docs suggest that "level" property is a minimum inclusive level.

Output from provided example
image

EDIT:
Also, some details, the empty line in my output is not from log.trace, and when using a file transport

{
    level: 'trace',
    target: 'pino/file',
    options: {
      destination: `./pino.log`,
    },
},

it does include the trace line in pino.log file.

@jsumners
Copy link
Member

Possibly there is a bug?

const pino = require('pino');
const log = pino({});

log.info('pino.info');
log.trace('pino.trace');
log.warn('pino.warn')
❯ node index.js|./node_modules/.bin/pino-pretty -L trace
[08:43:34.781] INFO (12635): pino.info
[08:43:34.781] WARN (12635): pino.warn

Would you like to send a Pull Request to address this issue? Remember to add unit tests.

@jmjf
Copy link

jmjf commented Sep 24, 2023

Is this a pino configuration issue?

const pino = require('pino');

const transport = pino.transport({
  targets: [
    {
      level: 'trace',
      target: 'pino-pretty',
    },
		{
			level: 'trace',
			target: 'pino/file',
			destination: 1,
		}
  ],
});

const log1 = pino({}, transport);

log1.fatal('log1.fatal');
log1.error('log1.error');
log1.warn('log1.warn');
log1.info('log1.info');
log1.debug('log1.debug');
log1.trace('log1.trace');

const log2 = pino({level: 'trace'}, transport);

log2.fatal('log2.fatal');
log2.error('log2.error');
log2.warn('log2.warn');
log2.info('log2.info');
log2.debug('log2.debug');
log2.trace('log2.trace');

Output may be a bit messy, but log1 stops at INFO for both transports while log2 goes all the way to TRACE.

EDIT: Removing level from the transports also stops an INFO. The point being, pino configuration and pino-pretty configuration are different. You must set both to the same level, it seems.

@AndreasGalster2
Copy link

Is this a pino configuration issue?

const pino = require('pino');

const transport = pino.transport({
  targets: [
    {
      level: 'trace',
      target: 'pino-pretty',
    },
		{
			level: 'trace',
			target: 'pino/file',
			destination: 1,
		}
  ],
});

const log1 = pino({}, transport);

log1.fatal('log1.fatal');
log1.error('log1.error');
log1.warn('log1.warn');
log1.info('log1.info');
log1.debug('log1.debug');
log1.trace('log1.trace');

const log2 = pino({level: 'trace'}, transport);

log2.fatal('log2.fatal');
log2.error('log2.error');
log2.warn('log2.warn');
log2.info('log2.info');
log2.debug('log2.debug');
log2.trace('log2.trace');

Output may be a bit messy, but log1 stops at INFO for both transports while log2 goes all the way to TRACE.

EDIT: Removing level from the transports also stops an INFO. The point being, pino configuration and pino-pretty configuration are different. You must set both to the same level, it seems.

This worked for me, but I just noticed it doesn't work once you set a customLevel in your transport / log2 config.

@jmjf
Copy link

jmjf commented Nov 13, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants