import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
const seq = require('bunyan-seq');
async function bootstrap() {
const app = await NestFactory.create(AppModule,{
bufferLogs: true,
});
app.useLogger(new BunyanLoggerService({
projectId: 'NestJS-Microservice',
formatterOptions: {
outputMode: 'json',
},
customStreams:[seq.createStream({serverUrl: 'http://localhost:5341', apiKey: '123456789'})] ,
extraFields: {
app: 'extra-field-app',
sample: 'extra-field-sample'
}
}));
await app.listen(3000);
}
bootstrap();`
In the controller in just create a Logger instance as follows and uses it:
`private readonly logger = new Logger('AppController');`
Examples:
`this.logger.warn('English hello {lang}',{ lang: 'en' }); `