forked from winstonjs/winston
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
winstonjs#1567: document common transport options
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,7 @@ logger to use throughout your application if you so choose. | |
* [Transports] | ||
* [Multiple transports of the same type](#multiple-transports-of-the-same-type) | ||
* [Adding Custom Transports](#adding-custom-transports) | ||
* [Common Transport options](#common-transport-options) | ||
* [Exceptions](#exceptions) | ||
* [Handling Uncaught Exceptions with winston](#handling-uncaught-exceptions-with-winston) | ||
* [To Exit or Not to Exit](#to-exit-or-not-to-exit) | ||
|
@@ -743,6 +744,34 @@ module.exports = class YourCustomTransport extends Transport { | |
}; | ||
``` | ||
|
||
## Common Transport options | ||
|
||
As every transport inherits from [winston-transport], therefore it's possible to set | ||
a custom format and a custom log level on each separately: | ||
|
||
``` js | ||
const logger = winston.createLogger({ | ||
transports: [ | ||
new winston.transports.File({ | ||
filename: 'error.log', | ||
level: 'error', | ||
format: winston.format.json() | ||
}), | ||
new transports.Http({ | ||
level: 'warn', | ||
format: winston.format.json() | ||
}), | ||
new transports.Console({ | ||
level: 'info', | ||
format: winston.format.combine( | ||
winston.format.colorize(), | ||
winston.format.simple() | ||
) | ||
}) | ||
] | ||
}); | ||
``` | ||
|
||
## Exceptions | ||
|
||
### Handling Uncaught Exceptions with winston | ||
|
@@ -1135,6 +1164,7 @@ npm test | |
[nyc]: https://github.com/istanbuljs/nyc | ||
[assume]: https://github.com/bigpipe/assume | ||
[logform]: https://github.com/winstonjs/logform#readme | ||
[winston-transport]: https://github.com/winstonjs/winston-transport | ||
|
||
[Read the `[email protected]` documentation]: https://github.com/winstonjs/winston/tree/2.x | ||
|
||
|