Giter Club home page Giter Club logo

slf4j-logback-notes's Introduction

slf4j-logback-template

This logging template uses Slf4j API with Logback implementation

Why you should use Logging Framework

  • Have you ever bump or found yourself opening your project and running it but end up wondering where the hell that print statements is coming from and end up scanning all your classes just to delete that annoying print statement that in fact you written long time ago.
  • And also spending time just to delete all of print statements all over your project because you are ready to deploy or present your project and you don't want them to see your print statements and probably you dont want to delete those because they are very useful print statements in the future when debugging.
  • THATS WHEN YOU NEED A LOGGING FRAMEWORK

Why I used SLF4J(Simple Logging Facade for Java) and Logback framework library implementation

  • I Choose SLF4J as an API because it provides an abstraction on top of logging libraries that allows us developers to choose any of the logging library we want and achieve less coupling in logging libraries to switch to other libraries anytime we want
  • I Choose Logback as implementation because it is also the default logging library used in spring and why I don't choose Log4j-core got involved in one major security issue that affected big companies check out this link for full list of companies that got affected by security issue https://www.cybersecurity-help.cz/reports/ApacheLog4J.php thats why I don't choose Log4j-core as framework library implementation.

5 types of logging levels

  • INFO: Used when you want to log an important message.
  • WARN: Used when there some potential process that will lead to application error or unusual behavior but your program is still running.
  • DEBUG: Used when you want to log message that will be used when debugging.
  • TRACE: Used when you want every process of your application to be log usually this is verbose and messages here are not that needed // more comprehensive than debug log
  • ERROR: Used when your application hits an error that should be stopped and your functions are working properly for some reasons

Note

  • private static final org.slf4j.Logger = org.slf4j.LoggerFactory.getLogger(Classname.class); should be always declared as static and final we dont want many instance of logger in our application.
  • You can use @Slf4j annotation of project lombok to skip the boilerplate above. I recommend IntelliJ as IDE because it provides support for lombok unlike any other IDE's

For more reference

slf4j-logback-notes's People

Contributors

elleined avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.