# nestjs-log

> [![Build Status](https://github.com/zman2013/nestjs-log/workflows/Build%20and%20Release/badge.svg)](https://github.com/zman2013/nestjs-log/workflows/Build%20and%20Release/badge.svg) [![Coverage Status](https://coveralls.io/repos/github/zman2013/nestjs-log

Latest version **2.0.6** (published 2021-06-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install nestjs-log
pnpm add nestjs-log
yarn add nestjs-log
bun add nestjs-log
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.6 |
| Published | 2021-06-02 |
| First published | 2020-10-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 226.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | bibber |
| Keywords | logger, nestjs, winston |

## Links

- npm: https://www.npmjs.com/package/nestjs-log
- Repository: https://github.com/zman2013/nestjs-log
- Homepage: https://github.com/zman2013/nestjs-log#nestjs-logger
- Issues: https://github.com/zman2013/nestjs-log/issues
- npm.io page: https://npm.io/package/nestjs-log

## Dependencies (4)

- [moment](https://npm.io/package/moment.md) ^2.29.1
- [winston](https://npm.io/package/winston.md) ^3.3.3
- [@nestjs/common](https://npm.io/package/@nestjs/common.md) ^7.0.0
- [winston-daily-rotate-file](https://npm.io/package/winston-daily-rotate-file.md) ^4.5.0

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 2.0.6 (latest) — 2021-06-02
- 2.0.5 — 2021-03-17
- 2.0.3 — 2021-03-17
- 2.0.2 — 2021-03-15
- 2.0.1 — 2021-01-09
- 2.0.0 — 2021-01-09
- 1.3.0 — 2021-01-09
- 1.2.0 — 2021-01-09
- 1.1.0 — 2020-10-25
- 1.0.2 — 2020-10-21
- 1.0.1 — 2020-10-20
- 0.0.4 — 2020-10-20
- 0.0.3 — 2020-10-20
- 0.0.2 — 2020-10-20
- 0.0.1 — 2020-10-20

## README

# nestjs-log

[![Build Status](https://github.com/zman2013/nestjs-log/workflows/Build%20and%20Release/badge.svg)](https://github.com/zman2013/nestjs-log/workflows/Build%20and%20Release/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/zman2013/nestjs-log/badge.svg?branch=master)](https://coveralls.io/github/zman2013/nestjs-log?branch=master)
[![npm](https://img.shields.io/npm/v/nestjs-log.svg)](https://www.npmjs.com/package/nestjs-log/)

> A log can be used as nestjs system logger and application logger. Logs can be rotated based on date('YYYY-MM-DD-HH'), size limit(1G), and old logs will be removed after 14 days. This module wrapps winston.

## Usage

```Install
npm install nestjs-log
```

### example as application logger
```typescript
const log = getLog(TAG) // TAG is a label usually as same as the class

log.verbose(`msg`)
log.debug(`msg`)
log.info(`msg`)
log.warn(`msg`)
log.error(`msg`)

// also support splat
log.info('msg', any1, any2, any3)
log.info(obj)
```

### example as nestjs system logger
```typescript
const app = await NestFactory.create(AppModule, {
    logger: getLog('system').loggerService
  });
```

### environment variables
```js
log level: 
  process.env.LOG_LEVEL ?? 'info'

log dir: 
  process.env.LOG_DIR ?? './log'

log date pattern: 
  process.env.LOG_DATE_PATTERN ?? 'YYYY-MM-DD-HH'

log file name:
  process.env.LOG_FILE_NAME ?? 'app'

log file max size: 
  process.env.LOG_MAX_SIZE ?? '1024m'
  Maximum size of the file after which it will rotate. This can be a number of bytes, or units of kb, mb, and gb. If using the units, add 'k', 'm', or 'g' as the suffix. The units need to directly follow the number.

log file rotation policy: 
  process.env.LOG_MAX_FILES ?? '14d' 
  Maximum number of logs to keep. This can be a number of files or number of days. If using days, add 'd' as the suffix.

log to console:
  set process.env.NODE_ENV to 'dev'
```

---
_Source: https://npm.io/package/nestjs-log · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
