json-logger-service
Provides a Json Nest LoggerService.
Installation
$ npm i json-logger-service
Usage
Nest Json LoggerService implementation use
Configuring Nest to use a custom Json LoggerService.
import {NestFactory} from '@nestjs/core';
import {AppModule} from './app.module';
import {JsonLoggerService} from 'json-logger-service';
const bootstrap = async () => {
const app = await NestFactory.create(AppModule);
app.useLogger(new JsonLoggerService('NestServer'));
await app.listen(3000);
};
bootstrap();
Using a new Json logger in your classes
import {JsonLogger, LoggerFactory} from 'json-logger-service';
export class HelloWorldService {
private logger: JsonLogger = LoggerFactory.createLogger(HelloWorldService.name);
public getHello(): string {
this.logger.info('Hello World!');
return 'Hello World!';
}
}