12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- {
- "name": "log4js",
- "version": "0.6.29",
- "description": "Port of Log4js to work with node.",
- "keywords": [
- "logging",
- "log",
- "log4j",
- "node"
- ],
- "license": "Apache-2.0",
- "main": "./lib/log4js",
- "author": {
- "name": "Gareth Jones",
- "email": "gareth.nomiddlename@gmail.com"
- },
- "repository": {
- "type": "git",
- "url": "https://github.com/nomiddlename/log4js-node.git"
- },
- "bugs": {
- "url": "http://github.com/nomiddlename/log4js-node/issues"
- },
- "engines": {
- "node": ">=0.8"
- },
- "scripts": {
- "test": "vows --spec"
- },
- "directories": {
- "test": "test",
- "lib": "lib"
- },
- "dependencies": {
- "async": "~0.2.0",
- "readable-stream": "~1.0.2",
- "semver": "~4.3.3",
- "underscore": "1.8.2"
- },
- "devDependencies": {
- "sandboxed-module": "0.1.3",
- "underscore": "1.2.1",
- "vows": "0.7.0"
- },
- "browser": {
- "os": false
- },
- "readme": "# log4js-node [![Build Status](https://secure.travis-ci.org/nomiddlename/log4js-node.png?branch=master)](http://travis-ci.org/nomiddlename/log4js-node)\n\n[![NPM](https://nodei.co/npm/log4js.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/log4js/)\n\nThis is a conversion of the [log4js](https://github.com/stritti/log4js)\nframework to work with [node](http://nodejs.org). I've mainly stripped out the browser-specific code and tidied up some of the javascript. \n\nOut of the box it supports the following features:\n\n* coloured console logging\n* replacement of node's console.log functions (optional)\n* file appender, with log rolling based on file size\n* SMTP appender\n* GELF appender\n* hook.io appender\n* Loggly appender\n* Logstash UDP appender\n* multiprocess appender (useful when you've got worker processes)\n* a logger for connect/express servers\n* configurable log message layout/patterns\n* different log levels for different log categories (make some parts of your app log as DEBUG, others only ERRORS, etc.)\n\nNOTE: from log4js 0.5 onwards you'll need to explicitly enable replacement of node's console.log functions. Do this either by calling `log4js.replaceConsole()` or configuring with an object or json file like this:\n\n```javascript\n{\n appenders: [\n { type: \"console\" }\n ],\n replaceConsole: true\n}\n```\n\n## installation\n\nnpm install log4js\n\n\n## usage\n\nMinimalist version:\n```javascript\nvar log4js = require('log4js');\nvar logger = log4js.getLogger();\nlogger.debug(\"Some debug messages\");\n```\nBy default, log4js outputs to stdout with the coloured layout (thanks to [masylum](http://github.com/masylum)), so for the above you would see:\n```bash\n[2010-01-17 11:43:37.987] [DEBUG] [default] - Some debug messages\n```\nSee example.js for a full example, but here's a snippet (also in fromreadme.js):\n```javascript\nvar log4js = require('log4js'); \n//console log is loaded by default, so you won't normally need to do this\n//log4js.loadAppender('console');\nlog4js.loadAppender('file');\n//log4js.addAppender(log4js.appenders.console());\nlog4js.addAppender(log4js.appenders.file('logs/cheese.log'), 'cheese');\n\nvar logger = log4js.getLogger('cheese');\nlogger.setLevel('ERROR');\n\nlogger.trace('Entering cheese testing');\nlogger.debug('Got cheese.');\nlogger.info('Cheese is Gouda.');\nlogger.warn('Cheese is quite smelly.');\nlogger.error('Cheese is too ripe!');\nlogger.fatal('Cheese was breeding ground for listeria.');\n```\nOutput:\n```bash\n[2010-01-17 11:43:37.987] [ERROR] cheese - Cheese is too ripe!\n[2010-01-17 11:43:37.990] [FATAL] cheese - Cheese was breeding ground for listeria.\n``` \nThe first 5 lines of the code above could also be written as:\n```javascript\nvar log4js = require('log4js');\nlog4js.configure({\n appenders: [\n { type: 'console' },\n { type: 'file', filename: 'logs/cheese.log', category: 'cheese' }\n ]\n});\n```\n\n## configuration\n\nYou can configure the appenders and log levels manually (as above), or provide a\nconfiguration file (`log4js.configure('path/to/file.json')`), or a configuration object. The \nconfiguration file location may also be specified via the environment variable \nLOG4JS_CONFIG (`export LOG4JS_CONFIG=path/to/file.json`). \nAn example file can be found in `test/log4js.json`. An example config file with log rolling is in `test/with-log-rolling.json`.\nBy default, the configuration file is checked for changes every 60 seconds, and if changed, reloaded. This allows changes to logging levels to occur without restarting the application.\n\nTo turn off configuration file change checking, configure with:\n\n```javascript\nvar log4js = require('log4js');\nlog4js.configure('my_log4js_configuration.json', {});\n```\nTo specify a different period:\n\n```javascript\nlog4js.configure('file.json', { reloadSecs: 300 });\n```\nFor FileAppender you can also pass the path to the log directory as an option where all your log files would be stored.\n\n```javascript\nlog4js.configure('my_log4js_configuration.json', { cwd: '/absolute/path/to/log/dir' });\n```\nIf you have already defined an absolute path for one of the FileAppenders in the configuration file, you could add a \"absolute\": true to the particular FileAppender to override the cwd option passed. Here is an example configuration file:\n\n#### my_log4js_configuration.json ####\n```json\n{\n \"appenders\": [\n {\n \"type\": \"file\",\n \"filename\": \"relative/path/to/log_file.log\",\n \"maxLogSize\": 20480,\n \"backups\": 3,\n \"category\": \"relative-logger\"\n },\n {\n \"type\": \"file\",\n \"absolute\": true,\n \"filename\": \"/absolute/path/to/log_file.log\",\n \"maxLogSize\": 20480,\n \"backups\": 10,\n \"category\": \"absolute-logger\" \n }\n ]\n}\n``` \nDocumentation for most of the core appenders can be found on the [wiki](https://github.com/nomiddlename/log4js-node/wiki/Appenders), otherwise take a look at the tests and the examples.\n\n## Documentation\nSee the [wiki](https://github.com/nomiddlename/log4js-node/wiki). Improve the [wiki](https://github.com/nomiddlename/log4js-node/wiki), please.\n\nThere's also [an example application](https://github.com/nomiddlename/log4js-example).\n\n## Contributing\nContributions welcome, but take a look at the [rules](https://github.com/nomiddlename/log4js-node/wiki/Contributing) first.\n\n## License\n\nThe original log4js was distributed under the Apache 2.0 License, and so is this. I've tried to\nkeep the original copyright and author credits in place, except in sections that I have rewritten\nextensively.\n",
- "readmeFilename": "README.md",
- "homepage": "https://github.com/nomiddlename/log4js-node",
- "_id": "log4js@0.6.29",
- "_shasum": "3b07f57160cfb9a7bfca271913e8344e81862ec6",
- "_from": "log4js@>=0.4.1",
- "_resolved": "https://registry.npmjs.org/log4js/-/log4js-0.6.29.tgz"
- }
|