question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] System logs skipped on startup

See original GitHub issue

Hi,

I am using pino with configuration as illustrated below:

// app.module.ts
import { Module } from '@nestjs/common';
import { LoggerModule } from 'nestjs-pino';
import { AppController } from './app.controller';
import { AppService } from './app.service';

import * as pino from 'pino';

const logger = pino({
  level: process.env.NODE_ENV !== 'prod' ? 'debug' : 'info',
},pino.destination({
  minLength: 4096,
  sync: false,
}));

setInterval(function() {
  logger.flush();
}, 5000).unref();

@Module({
  imports: [
    LoggerModule.forRoot({
      pinoHttp: {
        logger,
        autoLogging: true,
        serializers: {
          err: pino.stdSerializers.err,
          req: r => {
            return {
              id: r.id,
              method: r.method,
              url: r.url,
            };
          },
          res: pino.stdSerializers.res,
        }
      },
    }),
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}

and

// main.ts
import { NestFactory } from '@nestjs/core';
import { Logger } from 'nestjs-pino';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule, { logger: false });
  app.useLogger(app.get(Logger));
  await app.listen(3000);
}
bootstrap();

But the logging output missed the system logging part.

> nest start --watch
[10:11:49 PM] Starting compilation in watch mode...

[10:11:53 PM] Found 0 errors. Watching for file changes.

{"level":30,"time":1604671913986,"pid":28435,"hostname":"2070iMac","context":"RoutesResolver","msg":"AppController {}:"}
{"level":30,"time":1604671913987,"pid":28435,"hostname":"2070iMac","context":"RouterExplorer","msg":"Mapped {, GET} route"}
{"level":30,"time":1604671913989,"pid":28435,"hostname":"2070iMac","context":"NestApplication","msg":"Nest application successfully started"}

It is expected to output as many as system logging output, which has logging form modules like NestFactory and InstanceLoader. Below is the output from the default logger.

[10:33:59 PM] Starting compilation in watch mode...

[10:34:00 PM] Found 0 errors. Watching for file changes.

[Nest] 30928   - 11/06/2020, 10:34:01 PM   [NestFactory] Starting Nest application...
[Nest] 30928   - 11/06/2020, 10:34:01 PM   [InstanceLoader] LoggerModule dependencies initialized +15ms
[Nest] 30928   - 11/06/2020, 10:34:01 PM   [InstanceLoader] LoggerCoreModule dependencies initialized +1ms
[Nest] 30928   - 11/06/2020, 10:34:01 PM   [InstanceLoader] AppModule dependencies initialized +0ms
[Nest] 30928   - 11/06/2020, 10:34:01 PM   [RoutesResolver] AppController {}: +6ms
[Nest] 30928   - 11/06/2020, 10:34:01 PM   [RouterExplorer] Mapped {, GET} route +1ms
[Nest] 30928   - 11/06/2020, 10:34:01 PM   [NestApplication] Nest application successfully started +4ms

Here are some sample code to reproduce this issue: https://github.com/wuminqi/example-pino-nestjs

Can you kindly offer a help on this?

Thanks.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
iamoleggacommented, Nov 3, 2022

@StevenLangbroek please add the link to the minimal example repo. I’ll reopen this issue then

1reaction
wuminqicommented, Nov 7, 2020

Hi, thanks for your kindly reply.

I realize this issue as I misconfigured TypeORM and all the error logs from [TypeOrmModule] is swallowed. I have no idea what exception it is.

I updated the sample repo by adding typeorm and some invalid configurations, link.

Using nestjs-pino, the startup output:

[8:57:07 AM] Starting compilation in watch mode...

[8:57:09 AM] Found 0 errors. Watching for file changes.





Using default logger, the startup output:

[8:50:58 AM] Starting compilation in watch mode...

[8:51:00 AM] Found 0 errors. Watching for file changes.

[Nest] 32827   - 11/07/2020, 8:51:00 AM   [NestFactory] Starting Nest application...
[Nest] 32827   - 11/07/2020, 8:51:00 AM   [InstanceLoader] LoggerModule dependencies initialized +48ms
[Nest] 32827   - 11/07/2020, 8:51:00 AM   [InstanceLoader] TypeOrmModule dependencies initialized +0ms
[Nest] 32827   - 11/07/2020, 8:51:00 AM   [InstanceLoader] LoggerCoreModule dependencies initialized +1ms
[Nest] 32827   - 11/07/2020, 8:51:00 AM   [InstanceLoader] AppModule dependencies initialized +0ms
[Nest] 32827   - 11/07/2020, 8:51:10 AM   [TypeOrmModule] Unable to connect to the database. Retrying (1)... +10000ms
Error: Handshake inactivity timeout
    at Handshake.<anonymous> (/Users/minqi/workspace/dirtySpace/aa/example-pino-nestjs/node_modules/mysql/lib/protocol/Protocol.js:160:17)
    at Handshake.emit (events.js:311:20)
    at Handshake._onTimeout (/Users/minqi/workspace/dirtySpace/aa/example-pino-nestjs/node_modules/mysql/lib/protocol/sequences/Sequence.js:124:8)
    at Timer._onTimeout (/Users/minqi/workspace/dirtySpace/aa/example-pino-nestjs/node_modules/mysql/lib/protocol/Timer.js:32:23)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)
    --------------------
    at Protocol._enqueue (/Users/minqi/workspace/dirtySpace/aa/example-pino-nestjs/node_modules/mysql/lib/protocol/Protocol.js:144:48)
    at Protocol.handshake (/Users/minqi/workspace/dirtySpace/aa/example-pino-nestjs/node_modules/mysql/lib/protocol/Protocol.js:51:23)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Windows skipping Sign In on startup - Microsoft Community
Whenever I start up Windows, on the sign in page, the option to enter a password/PIN flashes briefly, and then proceeds to show...
Read more >
SOLVED: PC skips BIOS and goes straight to homescreen - iFixit
Go to Control Panel > Power Options > choose what the Power buttons do (left side of page)> Change Settings that are currently...
Read more >
BIOS Startup Error Messages and Solutions | Fixing Windows ...
When a system has problems starting, it might display error messages at startup. These messages might come from the system BIOS (ROM BIOS...
Read more >
K50265550: ASM Event Log requests are not logging locally.
The most common reason is the use of a security logging profile(s) assigned to virtual servers that are using a 'Request Type' value...
Read more >
System is in boot run level ... will skip any checks" in Guardium ...
Problem. Constant "-W- System is in boot run level ... will skip any checks" in Guardium GIM.log and central_logger.log when attempt STAP install...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found