https://github.com/sofish/log2mongo
automatic log to mongodb
https://github.com/sofish/log2mongo
Last synced: over 1 year ago
JSON representation
automatic log to mongodb
- Host: GitHub
- URL: https://github.com/sofish/log2mongo
- Owner: sofish
- License: other
- Created: 2015-11-15T12:23:29.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-12-04T07:23:52.000Z (over 10 years ago)
- Last Synced: 2025-04-23T16:06:47.068Z (over 1 year ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 1
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

**注意:**Travis-ci 的执行 path 好奇怪,大家用拉下来执行 \`npm test\` 吧
# log2mongo
import JSON to mongodb, associate with [sofish/log2json](https://github.com/sofish/log2json) to manage nginx logs.
```php
$ npm install log2mongo -g
```
## Usage
It's a command line tool and should install with the `-g` flag.
```php
$ log2mongo config.js
```
The `config.js` should be a node module like this:
```js
module.exports = {
"db": "db-name",
"host": "127.0.0.1:27017",
"collection": "collection", // {function|string} collection to insert, or a function returns a string
"dir": "dir/contains/logs", // where to find logs
"skip": skip(filename) // {function} [optional] a function return Boolean, when True, file ignored
"separator": "•-•", // separator of your (nginx/apache/whatever) log fields
"map": [], // map with log fields that create by `split(separator)`
"username": "sofish", // [optional] db username
"password": "***" // [optional] db password
}
```
## Test
Simply run `npm test` to see what happens.