図1に示すように、依存関係を追加:log4jの依存性がspringbootの下で提供されています
<! - @ SLF4J注釈タスクとログ依存のタイミング- >
<依存>
<groupIdを> org.projectlombok </ groupIdを>
<たartifactId>ロンボク</たartifactId>
<オプション>に真</オプション>
</依存関係>
2は、必要SLF4Jログが生成@クラスに添加したログのログを生成するために直接使用することができ、より便利に
com.example.demo.Logをパッケージ化。
輸入lombok.extern.slf4j.Slf4j;
輸入org.junit.Test;
輸入org.junit.runner.RunWith;
輸入org.springframework.boot.test.context.SpringBootTest;
輸入org.springframework.test.context.junit4.SpringRunner;
/ **
* @author王慧
* @description日志
* @date 2020年1月8日
* /
@RunWith(SpringRunner.class)
@SpringBootTest
@ SLF4J
パブリッククラスSpringbootLoggerApplicationTests {
@Test
公共ボイドcontextLoads(){
}
@Test
公共ボイドロガー(){
log.info( "===== >>>>>ロガー()")。
}
}
3、ダウンロードしてプラグインをインストールロンボク
[設定]を開くにはCtrl + Altキー+ S