Logger global interceptor library for Nest apps
$ npm install @mariomorenodev/nest-response-logger
Copy the variables from the .env.example
file to the .env
file
$ cp .env.example .env
Or add variables to the environment
TZ=UTC
LOG_FILE_PATH=./logs/app.log
LOG_FILE_ENABLED=false
Add the NestResponseLogger service globally in the main.ts
file:
import { NestResponseLoggerService } from '@mariomorenodev/nest-response-logger';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule, {
logger: new NestResponseLoggerService(),
});
await app.listen(3000);
}
bootstrap();
Add the interceptor globally in the app.module.ts
file:
import { LoggerInterceptor } from '@mariomorenodev/nest-response-logger';
import { NestResponseLoggerModule } from '@mariomorenodev/nest-response-logger';
@Module({
imports: [NestResponseLoggerModule],
providers: [
AppService,
{
provide: APP_INTERCEPTOR,
useClass: LoggerInterceptor,
},
],
})
Nest response logger MIT licensed.