winston logger | Log into MongoDB | File | Console | nodejs tutorial
github link : https://github.com/Tariqu/winston_logger_example
```
const {
createLogger,
format,
transports
} = require("winston");
require('winston-mongodb').MongoDB;
const logger = createLogger({
transports: [
new transports.MongoDB({
db: process.env.MONGODB_URI,
level: 'silly',
options: {
useUnifiedTopology: true
}
}),
new transports.File({
filename: "error.log",
level: "error",
format: format.combine(format.timestamp(), format.json())
}),
new transports.File({
filename: "info.log",
level: "info",
format: format.combine(format.timestamp(), format.json())
}),
]
});
module.exports = logger;
```
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
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «winston logger | Log into MongoDB | File | Console | nodejs tutorial», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.