OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

pino won't print debug level logs in the console

  • Thread starter Thread starter Claim
  • Start date Start date
C

Claim

Guest
I am trying to display DEBUG level logs in my React application but none of them are being printed. There's no issue with any other levels, only DEBUG.

I am using pino v9.2.0 and React 18.2.0.

Here's my config:

Code:
const send = (level, logEvent) => sendLogToBackend(logEvent);

export const logger = pino({
  level: 'debug',
  browser: {
    serialize: true,
    transmit: {
      send,
    }
  },
  transport: {
    targets: [{
      target : 'pino-pretty',
      level: 'debug'
    }]
  }
});

console.log('########################');
logger.trace('TRACE LOG');
logger.debug('DEBUG LOG');
logger.info('INFO LOG');
logger.warn('WARN LOG');
logger.error('ERROR LOG');
logger.fatal('FATAL LOG');
console.log('########################');
  • And this is the output:

enter image description here

  • The send method is used to send the logs to the backend, which surprisingly WORKS with DEBUG level too.

What I tried:

  • Changed the global level to trace/debug
  • The transport level to trace/debug
  • Changed the level to 20 (which should be DEBUG)

<p>I am trying to display <code>DEBUG</code> level logs in my React application but none of them are being printed. There's no issue with any other levels, only <code>DEBUG</code>.</p>
<p>I am using pino v9.2.0 and React 18.2.0.</p>
<p>Here's my config:</p>
<pre><code>const send = (level, logEvent) => sendLogToBackend(logEvent);

export const logger = pino({
level: 'debug',
browser: {
serialize: true,
transmit: {
send,
}
},
transport: {
targets: [{
target : 'pino-pretty',
level: 'debug'
}]
}
});

console.log('########################');
logger.trace('TRACE LOG');
logger.debug('DEBUG LOG');
logger.info('INFO LOG');
logger.warn('WARN LOG');
logger.error('ERROR LOG');
logger.fatal('FATAL LOG');
console.log('########################');
</code></pre>
<ul>
<li>And this is the output:</li>
</ul>
<p><a href="https://i.sstatic.net/UwKr5VED.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/UwKr5VED.png" alt="enter image description here" /></a></p>
<ul>
<li>The <code>send</code> method is used to send the logs to the backend, which surprisingly WORKS with <code>DEBUG</code> level too.</li>
</ul>
<p>What I tried:</p>
<ul>
<li>Changed the global level to trace/debug</li>
<li>The transport level to trace/debug</li>
<li>Changed the level to 20 (which should be <code>DEBUG</code>)</li>
</ul>
 

Latest posts

M
Replies
0
Views
1
Mohit Pant
M
Top