1.0.2 • Published 2 years ago

@xpjs/nest-log4 v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

nest-log4

用法

1、引入日志模块

// app.module.ts
import { Module } from '@nestjs/common';
import { LogModule } from '@xpjs/nest-log4';

@Module({
  imports: [
    // 日志模块
    LogModule.register({
      appenders: { console: { type: 'stdout' } },
      categories: {
        default: { appenders: ['console'], level: 'info' },
      },
    }),
  ],
})
export class AppModule {}

日志的具体配置可查看log4js

2、在服务中使用

// service.ts
import { LogService } from '@xpjs/nest-log4';
import { Injectable, Inject } from '@nestjs/common';

@Injectable()
export class LogTestService {
  @Inject()
  private readonly logger: LogService;
}