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
> Winston is a node package that provides a simple and universal logging library. It supports **multiple transports**, such as file, console, and syslog. Winston is easy to use and can be **customized** to meet your specific needs.
15
-
>
16
15
17
16
Did you see the words `multiple transports` and `customized` in the above definition of `winston` (that I asked Google Bard to write)? Yeah, `winston` is probable the most sophisticated and customizable logger out there.
18
17
@@ -21,34 +20,25 @@ Did you see the words `multiple transports` and `customized` in the above defini
21
20
So we know that `winston` supports multiple transports, but what is a transport anyway?
22
21
23
22
> In `winston`, transport is essentially a storage device for your logs. Each instance of a `winston` logger can have multiple transports configured at different levels.
24
-
>
25
23
26
24
So transport is basically like where you want to store your logs.
27
25
28
26
There are some most basic ones like:
29
27
30
28
-**The Console**
31
-
32
-
```tsx
33
-
importwinstonfrom"winston"
34
-
35
-
exportconst logger =winston.createLogger(
36
-
{
37
-
transports: [
38
-
newwinston.transports.Console()
39
-
],
40
-
}
41
-
)
42
-
```
43
-
29
+
```tsx
30
+
importwinstonfrom"winston";
31
+
32
+
exportconst logger =winston.createLogger({
33
+
transports: [newwinston.transports.Console()],
34
+
});
35
+
```
44
36
-**Files**
45
-
46
-
```tsx
47
-
...
48
-
new winston.transports.File({ filename: "logs/all.log" })
Console and file are like the most basic ones, Console basically prints your logs to the console and file one just stores your log in the defined file. You can go crazy with the options and do a lot more stuff, like storing logs of only a specific `level`, let’s say `error` or something.
54
44
@@ -62,7 +52,7 @@ To upload your logs to them, you’ll need custom transport. `winston` give you
62
52
63
53
So basically custom transports are to upload your logs to some sort of storage or maybe do something else with it, like creating alerts and stuff.
0 commit comments