winston logger | Log into MongoDB | File | Console | nodejs tutorial

preview_player
Показать описание
```
const {

createLogger,
format,
transports
} = require("winston");
require('winston-mongodb').MongoDB;
const logger = createLogger({
transports: [
new transports.MongoDB({
level: 'silly',
options: {
useUnifiedTopology: true
}
}),
new transports.File({
level: "error",
}),
new transports.File({
level: "info",
}),
]
});
```

Hello friends its me tarique akhtar ansari in this video I am going to show you how to log properly into console,
into file and into the database using winston don't worry guyyz I have given github link in the discription,

you can checkout and get get the source code of this video.



let me tell you the to most importent reason of doing log



1. first thing as a developer point of view

-------------------------------------------

when we work on development we normally use console to see application log

but once your application moved into the production server and users are started using your application

then if somthing went wrong like application crashed or giving wrong output then you can't check into the console

but if you have log into file or into the database then you can check and identify the mistakes ok



2. sencond thing

----------------

if you have log of every activity happening in your application then you can process that log and generate some useful information

Just take an example of facebook. Facebook has billions of users and they have log of every activity of the users



1. just imagine how many different types of information can generate from that log

even we can't imagine how much information we can generate from log



ok so lets jump into the coding



install

--------

1. npm install winston

2. npm install winston-mongodb



then create winston logger object inside that object define transports then use that object to log into console | file | mongodb
Рекомендации по теме
Комментарии
Автор

Dude that was amazing! So comprehensive!

SogMosee
Автор

It was fast and right into the point. Thanks for the effort

mdsadiqurrahman
Автор

Thanks man! after watching your video now the concept is clear to me. Big help, thanks again

abeercodes
Автор

how to store it mysql db please make video

manjunathab
Автор

Your videos are precise and accurate.
Thanks Babaji!

banjovictor
Автор

Thanks mate exactly what I wanted ! continue like that !

perlimpinpin
Автор

every one is explaining with only file upload in need u to make a form with some fields + file upload and then submit.
that will be more helpful.(reactjs + nodejs +Mysql)

prajeethkumarreddy
Автор

logger is not terminating when running your code, always have to stop the process manually in VS Code. Any idea why?

coding
Автор

thanks, that's really helpful for me

VivekSharma-oztv
Автор

can i save this messege as json format in my db

mdgolamkibria
Автор

How can we add coloured logs in the file through winston?

yateshchhabra
Автор

How Could You Use Winston-mongodb With the Version 4 Of MongoDB And The version 4 of Winston While in The Documentation
exist That Winston-mongodb package Work onLY Withe version 3 of Both Winston and Mongodb.

ayoubalem
Автор

Why the meta prop in the MongoDB is null? How are you going to set it to the error object so that you get the complete stack trace saved in the meta prop?

academyonnet
Автор

How does anyone put the logs in a folder? I cant find it anywhere. I want a logs folder with my errors and requests and not in the root.

merknator
Автор

is there any way we can create a transport for oracle DB?

tarunpanwar
Автор

Hey, how do we save the log file with the timestamp?

srinivasqa
Автор

Thanks for this ...I clearly understood usage of Winston by this video..I have one query if I want to transfer this log to logstash how can I do this ?

lakshmiamujuru
Автор

please make one tutorial for forgot password rest api using node js

roshangujiri
Автор

Pls put a video on mobile no verification using node .js 😪

shyamprakashm