# koa-log4

> log4js-node support Koa-middleware

Latest version **2.3.2** (published 2018-12-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install koa-log4
pnpm add koa-log4
yarn add koa-log4
bun add koa-log4
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.3.2 |
| Published | 2018-12-15 |
| First published | 2016-04-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/koa-log4) |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 82 |
| Author | Do Minh Hai |
| Maintainers | dominhhai |
| Keywords | log4js, Koa, logger |

## Links

- npm: https://www.npmjs.com/package/koa-log4
- Repository: https://github.com/dominhhai/koa-log4js
- Homepage: https://github.com/dominhhai/koa-log4js#readme
- Issues: https://github.com/dominhhai/koa-log4js/issues
- npm.io page: https://npm.io/package/koa-log4

## Dependencies (1)

- [log4js](https://npm.io/package/log4js.md) ^3.0.6

## 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.3.2 (latest) — 2018-12-15
- 2.3.0 — 2017-11-18
- 1.2.0 — 2017-11-18
- 2.2.1 — 2017-04-20
- 1.1.1 — 2017-04-20
- 2.2.0 — 2017-02-23
- 2.1.0 — 2016-11-24
- 1.1.0 — 2016-11-24
- 2.0.2 — 2016-10-14
- 1.0.2 — 2016-10-14
- 2.0.1 — 2016-04-20
- 1.0.1 — 2016-04-20
- 2.0.0 — 2016-04-20
- 1.0.0 — 2016-04-20

## README

# koa-log4js
A wrapper for [log4js-node](https://github.com/nomiddlename/log4js-node) which support [Koa](https://github.com/koajs/koa) logger middleware.
Log message is forked from Express (Connect) logger [file](https://github.com/nomiddlename/log4js-node/blob/master/lib/connect-logger.js).

## Note
This branch is use to [Koa v2.x](https://github.com/koajs/koa/tree/v2.x).
To use Koa v0.x & v1.x, please check the [master](https://github.com/dominhhai/koa-log4js/tree/master) branch.

## Installation

#### for koa v0.x & v1.x
```
$ npm i --save koa-log4@1
```

#### for koa v2.x
```
$ npm i --save koa-log4@2
```

___The default logger is for [koa v2.x](https://github.com/koajs/koa/tree/v2.x)___
```
$ npm i --save koa-log4
```

## Usage
Config koa-log4js is same as the original [log4js-node](https://github.com/nomiddlename/log4js-node).

### Normal log4js way
This way is same as the original [log4js-node](https://github.com/nomiddlename/log4js-node).

```javascript
const log4js = require('koa-log4')

const log = log4js.getLogger('index')
log.info('index do some awesome things')
```

### Koa-middleware way
Similar to use Express (Connect) logger middleware.

```javascript
const log4js = require('koa-log4')
app.use(log4js.koaLogger(log4js.getLogger("http"), { level: 'auto' }))
```

## Full Example
Check [this repo](https://github.com/dominhhai/koa-log4js-example/tree/v2.x) for full example with `Koa v2`.

## Others
See [here](https://github.com/nomiddlename/log4js-node) for more info.

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