Skip to content

Commit

Permalink
#1567: document common transport options (#1723)
Browse files Browse the repository at this point in the history
* #1567: document common transport options

* Update README.md
  • Loading branch information
kwiatkk1 authored and DABH committed Oct 27, 2019
1 parent ae2335b commit 64744d7
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -743,6 +744,34 @@ module.exports = class YourCustomTransport extends Transport {
};
```

## Common Transport options

As every transport inherits from [winston-transport], it's possible to set
a custom format and a custom log level on each transport 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
Expand Down Expand Up @@ -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 `winston@2.x` documentation]: https://github.com/winstonjs/winston/tree/2.x

Expand Down

0 comments on commit 64744d7

Please sign in to comment.