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

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.

主站蜘蛛池模板: 蓝田县| 和林格尔县| 南丹县| 留坝县| 名山县| 湛江市| 灌南县| 托克逊县| 渭源县| 张家界市| 德清县| 抚宁县| 石门县| 称多县| 鄄城县| 衢州市| 金堂县| 什邡市| 饶河县| 平昌县| 海原县| 房产| 即墨市| 琼海市| 广南县| 民勤县| 贺兰县| 抚宁县| 盐山县| 凌海市| 惠安县| 内江市| 乌拉特中旗| 罗甸县| 华宁县| 惠州市| 武宁县| 新建县| 郎溪县| 舞钢市| 福清市|