From past few days I am avidly following videos in your channel . This channel really comprehensive ,beginner friendly and not having any paid courses or ads like other big youtubers .... Simply #noShitTotallyHit. I hope you will continue this LLD series weekly
Very good explanation :) But I don't think we need chain of responsibility design pattern here, we can use Factory pattern directly to get the object of the required Logger as we only need one logger at a time
I think your logger class breaks " OPEN AND CLOSED PRINCIPLE" because if there are any other type of log files, then u have to create methods for them. If I wrong, then please correct me. Also we can use factory design pattern instead of chain responsibility pattern.
couple of issues with the design. We don't need chain of responsibility here. How to make log levels configurable so let us assume if we want to only print logs above INFO level.
COR fits nicely here actually. For configuration part, we can maintain a threshold value that the user can configure and add a check for this before printing(perhaps the abstractlogger)
Very good explanation :) But I don't think we need chain of responsibility design pattern here, we can use Factory pattern directly to get the object of the required Logger as we only need one logger at a time.
@@bhawanasahu3000 let's take example of log4j, we can enable certain log level in the system like ERROR or INFO etc, this is how the error levels are defined ALL < DEBUG < INFO < WARN < ERROR < FATAL < OFF e.g. if log level is set to warn, then only warn, error, fatal will be printed, rest all logs with other log levels will be disabled like debug, info etc will not be printed Now you can see that chain of responsibility comes in handy here, lets say I have used warn as log level in log 4j and in code i have different logs like debug, info, error etc lets take error, it will go to all handlers and check what log level is enabled e.g. it will first go to debug handler, is it enabled, no, then go to next info and next warn, okay warn is enabled but the log level to be printed is error, then it will move to next handler i.e. error okay now it matches the log level to be printed and also at the system level warn is enabled and error handler is eligible for printing this log There is a order of execution here where the request may or may not be fulfilled based on what log level is enabled and the order which the request should be served is defined by the chain of responsibility pattern i.e. ALL < DEBUG < INFO < WARN < ERROR < FATAL < OFF
Yes, absolutely.If the root level is ERROR, we expect it to display log.info() and log.error() statements only in actual logging framework.This can be easily handled by individual loggers by comparing their actual levels with root level.There is never a delegation needed.
Complete code can be downloaded from :
github.com/TheTechGranth/thegranths/tree/master/src/main/java/SystemDesign/LoggingFramework
Don't you think this will print multiple levels if you log debug? we only need one logger
Great explanation of logger design, and clear design pattern mapping. Thank you.
From past few days I am avidly following videos in your channel . This channel really comprehensive ,beginner friendly and not having any paid courses or ads like other big youtubers .... Simply #noShitTotallyHit. I hope you will continue this LLD series weekly
Hope content was helpful. Do like the videos and subscribe and share with others 🙂
Thank you for your contributing to the community. I have more than I hope from you
Excellent explanation and easy to understand. Kudos to you Bro 👍👏
Quite informative ! Good way of thinking about related design patterns.
Glad it was helpful. Do like and subscribe and share with others 🙂
This was very detailed explanation of logging system, really helped, thanks
Do like, subscribe and share with others
Thanks for such an awesome video explaining mapping of design patterns applications with a relatable example!
Glad it was helpful. Do like and subscribe and share with others 🙂
This is quite informative with very nice demo on use of design patterns.
Thanks!!!
Nice job 👏
Glad it was helpful. Do like and subscribe and share with others 🙂
very useful use case which covers Singelton, chain of responsibility and observer pattern
Very good explanation :)
But I don't think we need chain of responsibility design pattern here, we can use Factory pattern directly to get the object of the required Logger as we only need one logger at a time
great explanation. really liked the way the problem is approached.
Best explanation of logger , and great usage of design pattern
Thank you so much 'The Tech Granth'
Should we also consider to have a "String absolute_filename" when we are calling the fileObserver ? In which file will the data be logged ?
I think your logger class breaks " OPEN AND CLOSED PRINCIPLE" because if there are any other type of log files, then u have to create methods for them. If I wrong, then please correct me. Also we can use factory design pattern instead of chain responsibility pattern.
but in actuall logger, you set the logging level first and based on that level specific data is displayed
Really Helpful!
@thetechGranth Great video. Can you make system design video on tagging system,
Excellent
Thank you :)
Hope it was helpful. Do like and subscribe and share with others 🙂
I got same question in NI LLD interview
bro you literally made a simple design more complex and mess
couple of issues with the design. We don't need chain of responsibility here. How to make log levels configurable so let us assume if we want to only print logs above INFO level.
COR fits nicely here actually. For configuration part, we can maintain a threshold value that the user can configure and add a check for this before printing(perhaps the abstractlogger)
Very good explanation :)
But I don't think we need chain of responsibility design pattern here, we can use Factory pattern directly to get the object of the required Logger as we only need one logger at a time.
I also agree. Not sure why we need chaining here? we only need to log one level at time
I answered the same in one of my interview, but interviewer restricted his expectations to chain of responsibility pattern & I never understood why.
@@bhawanasahu3000
let's take example of log4j, we can enable certain log level in the system like ERROR or INFO etc, this is how the error levels are defined ALL < DEBUG < INFO < WARN < ERROR < FATAL < OFF e.g. if log level is set to warn, then only warn, error, fatal will be printed, rest all logs with other log levels will be disabled like debug, info etc will not be printed
Now you can see that chain of responsibility comes in handy here, lets say I have used warn as log level in log 4j and in code i have different logs like debug, info, error etc lets take error, it will go to all handlers and check what log level is enabled e.g. it will first go to debug handler, is it enabled, no, then go to next info and next warn, okay warn is enabled but the log level to be printed is error, then it will move to next handler i.e. error okay now it matches the log level to be printed and also at the system level warn is enabled and error handler is eligible for printing this log
There is a order of execution here where the request may or may not be fulfilled based on what log level is enabled and the order which the request should be served is defined by the chain of responsibility pattern i.e. ALL < DEBUG < INFO < WARN < ERROR < FATAL < OFF
Yes, absolutely.If the root level is ERROR, we expect it to display log.info() and log.error() statements only in actual logging framework.This can be easily handled by individual loggers by comparing their actual levels with root level.There is never a delegation needed.
Yes, I also think the same why do we need a chain of responsibility here? does anyone get a solution?