JAvaログシステムの違い:Commons LoggingとSLF 4 J
2170 ワード
今日spring apiを見て、springはCommons LoggingではなくSLF 4 Jを採用することを提案しました.理由は以下の通りです.
SLF4J is a cleaner dependency and more efficient at runtime than commons-logging because it uses compile-time bindings instead of runtime discovery of the other logging frameworks it integrates
SLF 4 Jはコンパイル時バインディングを採用し、commons-loggingは実行時検索のアルゴリズムを採用している.だからSLF 4 jを採用して書くコードの効率をもっと高くすることができて、もとはログシステムに対してずっとあまり気にしていないで、意外にもこのような言い方があります.
コードを書くときはいつもcommons-loggingがあることに気づいた.JArの依存性、
直接削除され、maven依存は次のようになります.
SLF4J is a cleaner dependency and more efficient at runtime than commons-logging because it uses compile-time bindings instead of runtime discovery of the other logging frameworks it integrates
SLF 4 Jはコンパイル時バインディングを採用し、commons-loggingは実行時検索のアルゴリズムを採用している.だからSLF 4 jを採用して書くコードの効率をもっと高くすることができて、もとはログシステムに対してずっとあまり気にしていないで、意外にもこのような言い方があります.
コードを書くときはいつもcommons-loggingがあることに気づいた.JArの依存性、
直接削除され、maven依存は次のようになります.
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.0.0.RELEASE</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.5.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<scope>runtime</scope>
</dependency>
</dependencies>