Skip to content

Commit

Permalink
Merge pull request #354 from Henderxx/master
Browse files Browse the repository at this point in the history
update readme, add "level" option
  • Loading branch information
wbt authored Jun 22, 2022
2 parents d2182f1 + df9235d commit 845a75e
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ The DailyRotateFile transport can rotate files by minute, hour, day, month, year
* **createSymlink**: Create a tailable symlink to the current active log file. (default: false)
* **symlinkName**: The name of the tailable symlink. (default: 'current.log')
* **auditHashType**: Use specified hashing algorithm for audit. (default: 'sha256')
* **level**: Name of the logging level that will be used for the transport, if not specified option from `createLogger` method will be used

## Usage
``` js
var winston = require('winston');
require('winston-daily-rotate-file');

var transport = new winston.transports.DailyRotateFile({
level: 'info',
filename: 'application-%DATE%.log',
datePattern: 'YYYY-MM-DD-HH',
zippedArchive: true,
Expand All @@ -60,6 +62,44 @@ The DailyRotateFile transport can rotate files by minute, hour, day, month, year

logger.info('Hello World!');

```
using multiple transports
``` js
var winston = require('winston');
require('winston-daily-rotate-file');

var transport1 = new winston.transports.DailyRotateFile({
filename: 'application-%DATE%.log',
datePattern: 'YYYY-MM-DD-HH',
zippedArchive: true,
maxSize: '20m',
maxFiles: '14d'
});

var transport2 = new winston.transports.DailyRotateFile({
level: 'error',
filename: 'application-error-%DATE%.log',
datePattern: 'YYYY-MM-DD-HH',
zippedArchive: true,
maxSize: '20m',
maxFiles: '14d'
});

transport.on('rotate', function(oldFilename, newFilename) {
// do something fun
});

var logger = winston.createLogger({
level: 'info'
transports: [
transport1, // will be used on info level
transport2 // will be used on error level
]
});

logger.info('Hello World!');
logger.error('Hello Error!');

```

### ES6
Expand Down

0 comments on commit 845a75e

Please sign in to comment.