https://github.com/koajs/accesslog
Middleware for common log format access logs
https://github.com/koajs/accesslog
Last synced: 2 months ago
JSON representation
Middleware for common log format access logs
- Host: GitHub
- URL: https://github.com/koajs/accesslog
- Owner: koajs
- License: mit
- Created: 2014-11-19T12:43:54.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-10-12T23:02:00.000Z (6 months ago)
- Last Synced: 2024-10-29T15:32:22.644Z (6 months ago)
- Language: JavaScript
- Size: 109 KB
- Stars: 20
- Watchers: 8
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-koa - accesslog - Middleware for common log format access logs (Middleware)
- awesome-koa - koa-accesslog - 通用日志格式访问日志的中间件。   (仓库 / 中间件)
README
# [Accesslog](https://github.com/koajs/accesslog)
Output [Common Log Format](http://en.wikipedia.org/wiki/Common_Log_Format) access logs to any stream. Defaults to `process.stdout`.
> Notice: We recommend using `@koa/access-log` for installation, as both `koa-accesslog` and `@koa/access-log` refer to the same module. However, in our next major version bump (v2), we will deprecate `koa-accesslog` and only maintain `@koa/access-log`.
## Install
```bash
# npm ..
npm i koa-accesslog
# yarn ..
yarn add koa-accesslog
```or
```bash
# npm ..
npm i @koa/access-log
# yarn ..
yarn add @koa/access-log
```## Usage
```js
const Koa = require('koa');
const accesslog = require('koa-accesslog');
// or
// const accesslog = require('@koa/access-log');
const app = new Koa();app.use(accesslog());
```## Output
```
127.0.0.1 - - [19/Nov/2014:13:47:37 +0100] "GET / HTTP/1.X" 404 -
```## Configure
You may configure Accesslog to use any writable stream such as an
instance of `stream.PassThrough` as seen below.```js
const log = new stream.PassThrough();
app.use(accesslog(log));
```## License
[MIT](LICENSE)