官术网_书友最值得收藏!

Fine-tuning with logging

Logging is very important in each application to debug and analyze the application's bugs during runtime. If you are working with the old-fashioned Spring Framework, then you have to configure the logging framework explicitly in your application. But Spring Boot provides support for several logging frameworks and also allows you to customize and fine-tune logging in to your Spring application. Spring Boot includes, by default:

  • SLF4J: Logging facade
  • Logback: SLF4J implementation

But as a best practice, stick to default logging in your application and use the SLF4J abstraction in the application code. Spring Boot also supports other logging frameworks such as Java Util Logging, Log4J, and Log4J2. You can use another logging frameworks by just adding a dependency, as follows:

<dependency> 
   <groupId>org.springframework.boot</groupId> 
   <artifactId>spring-boot-starter-websocket</artifactId> 
   <exclusions> 
         <exclusion> 
               <groupId>ch.qos.logback</groupId> 
               <artifactId>logback-classic</artifactId> 
         </exclusion> 
   </exclusions> 
</dependency> 
<dependency> 
   <groupId>org.slf4j</groupId> 
   <artifactId>slf4j-log4j12</artifactId> 
</dependency> 

According to this code, we are using log4j12 instead of the logback logging framework. Let's see how to configure logging output in a Spring application.

主站蜘蛛池模板: 龙里县| 郑州市| 都昌县| 慈溪市| 大悟县| 厦门市| 施秉县| 仁寿县| 遂平县| 偏关县| 清水县| 开平市| 怀来县| 桐梓县| 海安县| 琼海市| 海兴县| 加查县| 泗阳县| 青州市| 武冈市| 津市市| 安陆市| 滕州市| 利辛县| 南投县| 绥芬河市| 博罗县| 于都县| 射阳县| 雷波县| 长垣县| 上高县| 呼图壁县| 太和县| 山西省| 洞头县| 井冈山市| 鄂托克前旗| 伊川县| 东平县|