You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+38-2
Original file line number
Diff line number
Diff line change
@@ -95,10 +95,35 @@ You can work with this logger in the same way that you work with the default log
95
95
// Adding / Removing Transports
96
96
// (Yes It's chainable)
97
97
//
98
-
logger.add(winston.transports.File)
99
-
.remove(winston.transports.Console);
98
+
logger
99
+
.add(winston.transports.File)
100
+
.remove(winston.transports.Console);
100
101
```
101
102
103
+
You can also wholesale reconfigure a `winston.Logger` instance using the `configure` method:
104
+
105
+
```js
106
+
var logger =newwinston.Logger({
107
+
level:'info',
108
+
transports: [
109
+
new (winston.transports.Console)(),
110
+
new (winston.transports.File)({ filename:'somefile.log' })
111
+
]
112
+
});
113
+
114
+
//
115
+
// Replaces the previous transports with those in the
116
+
// new configuration wholesale.
117
+
//
118
+
logger.configure({
119
+
level:'verbose',
120
+
transports: [
121
+
newrequire('winston-daily-rotate-file')(opts)
122
+
]
123
+
});
124
+
```
125
+
126
+
102
127
### Logging with Metadata
103
128
In addition to logging string messages, winston will also optionally log additional JSON metadata objects. Adding metadata is simple:
104
129
@@ -641,6 +666,17 @@ Configuring output for this style is easy, just use the `.cli()` method on `wins
641
666
### Filters and Rewriters
642
667
Filters allow modifying the contents of **log messages**, and Rewriters allow modifying the contents of **log meta** e.g. to mask data that should not appear in logs.
643
668
669
+
Both filters and rewriters are simple Arrays of functions which can be provided when creating a `new winston.Logger(options)`. e.g.:
0 commit comments