java 日志
程序员文章站
2024-01-23 18:17:16
...
门面模式是什么
java 日志讲解
SLF4J
- Java简易日志门面(Simple Logging Facade for Java,缩写SLF4J),是一套包装Logging 框架的界面程式,以外观模式实现。可以在软件部署的时候决定要使用的 Logging 框架,目前主要支援的有Java Logging API、Log4j及logback等框架。以MIT 授权方式发布。
总结
- 要用SLF4J 和log4j ,lo4j2,LogBack 3个中的其中一个.
SLF4J: Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting *Error.
SLF4J: See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.slf4j.impl.StaticLoggerBinder.<init>(StaticLoggerBinder.java:72)
at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:45)
at org.apache.tmpspark.internal.Logging$.org$apache$tmpspark$internal$Logging$$isLog4j12(Logging.scala:205)
at org.apache.tmpspark.internal.Logging$class.initializeLogging(Logging.scala:119)
at org.apache.tmpspark.internal.Logging$class.initializeLogIfNecessary(Logging.scala:108)
at org.apache.tmpspark.util.Utils$.initializeLogIfNecessary(Utils.scala:22)
at org.apache.tmpspark.internal.Logging$class.initializeLogIfNecessary(Logging.scala:99)
at org.apache.tmpspark.util.Utils$.initializeLogIfNecessary(Utils.scala:22)
at org.apache.tmpspark.internal.Logging$class.log(Logging.scala:46)
at org.apache.tmpspark.util.Utils$.log(Utils.scala:22)
at org.apache.tmpspark.internal.Logging$class.logInfo(Logging.scala:54)
at org.apache.tmpspark.util.Utils$.logInfo(Utils.scala:22)
at org.apache.tmpspark.util.Utils$$anonfun$startServiceOnPort$1.apply$mcVI$sp(Utils.scala:76)
at scala.collection.immutable.Range.foreach$mVc$sp(Range.scala:160)
at org.apache.tmpspark.util.Utils$.startServiceOnPort(Utils.scala:66)
at org.apache.tmpspark.deploy.yarn.AkkaUtils$.createActorSystem(AkkaUtils.scala:24)
at org.apache.tmpspark.SparkEnv$.create(SparkEnv.scala:94)
at org.apache.tmpspark.SparkEnv$.createDriverEnv(SparkEnv.scala:46)
at org.apache.tmpspark.scheduler.SparkContext.createSparkEnv(SparkContext.scala:65)
at org.apache.tmpspark.scheduler.SparkContext.<init>(SparkContext.scala:30)
at org.apache.tmpspark.Test$.main(Test.scala:12)
at org.apache.tmpspark.Test.main(Test.scala)
Caused by: java.lang.IllegalStateException: Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting *Error. See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
at org.slf4j.impl.Log4jLoggerFactory.<clinit>(Log4jLoggerFactory.java:54)
... 22 more
- Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting *Error.
- log4j-over-slf4j.jar 从log4j到slf4j
- slf4j-log4j12 从 slf4j到-log4j
- 造成循环,导致错误,应该去除log4j-over-slf4j.jar,因为我们一般用slf4j,门面.
mvn dependency:tree
- 用mvn dependency:tree 查看依赖排除后,idea中还是有.
- 用mvn dependency:tree -Dverbose 太长了,idea显示不下.
- 用mvn dependency:tree -Dverbose > file.txt