根據spring啓動文檔(最新),它提到spring啓動在內部使用logback。在調試模式下使用log4j啓動器不打印的彈簧啓動
我已經使用的log4j起動機下面排除的logback如上所述
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
</dependency>
</dependencies>
和例如如果以下命令在調試模式下運行(假設sboot1是我的超級罐子)
java -jar target\sboot1-1.0.jar --debug
我沒有得到它正在使用的logback這顯示「排除」和「包裹」和其他必要信息之前生成的調試日誌。
如何在使用log4j等其他日誌框架時獲取--debug日誌?
它適用於我。你有沒有想過將你的主要方法中的參數傳遞給你的'SpringApplication'?像這樣:'SpringApplication.run(YourApplication.class,args);' –
謝謝你的回覆@AndyWilkinson,但是參數是作爲參數傳遞的。上傳了示例代碼[here](https://github.com/mnkartik/stackoverflow/blob/master/sboot1.zip)。嘗試從pom.xml中註銷log4j啓動器依賴項後,運行命令'java -jar target \ sboot1-1.0.jar --debug',那些日誌將不會被打印並通過註釋嘗試另一種方式,日誌將被打印爲logback依賴。 –