Jakarta Commons logging package

本文介绍了commons-logging.jar,它是Apache Commons包中含日志功能的必备jar包。运行时会先找log4j,没有则找JDK1.4的java.util.logging,都没有就用自带的Simple Logger。它用于兼容两个logger,底层Logger可切换,建议使用高性能的log4j,Hibernate已准备好其配置文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  • commons-logging.jar:

Apache Commons包中的一个,包含了日志功能,必须使用的jar包。这个包本身包含了一个Simple Logger,但是功能很弱。在运行的时候它会先在CLASSPATH找log4j,如果有,就使用log4j,如果没有,就找JDK1.4带的java.util.logging,如果也找不到就用Simple Logger。commons-logging.jar的出现是一个历史的的遗留的遗憾,当初Apache极力游说Sun把log4j加入JDK1.4,然而JDK1.4项目小组已经接近发布JDK1.4产品的时间了,因此拒绝了Apache的要求,使用自己的java.util.logging,这个包的功能比log4j差的很远,性能也一般。后来Apache就开发出来了commons-logging.jar用来兼容两个logger。因此用commons-logging.jar写的log程序,底层的Logger是可以切换的,你可以选择log4j,java.util.logging或者它自带的Simple Logger。不过我仍然强烈建议使用log4j,因为log4j性能很高,log输出信息时间几乎等于System.out,而处理一条log平均只需要5us。你可以在Hibernate的src目录下找到Hibernate已经为你准备好了的log4j的配置文件,你只需要到Apache 网站去下载log4j就可以了。commons-logging.jar也是必须的jar包。

sbt:spark-app> assembly [warn] multiple main classes detected: run 'show discoveredMainClasses' to see the list [error] 37 error(s) were encountered during the merge: [error] stack trace is suppressed; run last assembly for the full output [error] (assembly) [error] Deduplicate found different file contents in the following: [error] Jar name = protobuf-java-3.19.6.jar, jar org = com.google.protobuf, entry target = google/protobuf/api.proto [error] Jar name = spark-core_2.12-3.5.0.jar, jar org = org.apache.spark, entry target = google/protobuf/api.proto [error] Deduplicate found different file contents in the following: [error] Jar name = protobuf-java-3.19.6.jar, jar org = com.google.protobuf, entry target = google/protobuf/field_mask.proto [error] Jar name = spark-core_2.12-3.5.0.jar, jar org = org.apache.spark, entry target = google/protobuf/field_mask.proto [error] Deduplicate found different file contents in the following: [error] Jar name = commons-logging-1.1.3.jar, jar org = commons-logging, entry target = org/apache/commons/logging/Log.class [error] Jar name = jcl-over-slf4j-2.0.7.jar, jar org = org.slf4j, entry target = org/apache/commons/logging/Log.class [error] Deduplicate found different file contents in the following: [error] Jar name = protobuf-java-3.19.6.jar, jar org = com.google.protobuf, entry target = google/protobuf/struct.proto [error] Jar name = spark-core_2.12-3.5.0.jar, jar org = org.apache.spark, entry target = google/protobuf/struct.proto [error] Deduplicate found different file contents in the following: [error] Jar name = commons-logging-1.1.3.jar, jar org = commons-logging, entry target = org/apache/commons/logging/impl/NoOpLog.class [error] Jar name = jcl-over-slf4j-2.0.7.jar, jar org = org.slf4j, entry target = org/apache/commons/logging/impl/NoOpLog.class [error] Deduplicate found different file contents in the following: [error] Jar name = arrow-format-11.0.0.jar, jar org = org.apache.arrow, entry target = arrow-git.properties [error] Jar name = arrow-memory-core-11.0.0.jar, jar org = org.apache.arrow, entry target = arrow-git.properties [error] Jar name = arrow-memory-netty-11.0.0.jar, jar org = org.apache.arrow, entry target = arrow-git.properties [error] Jar name = arrow-vector-11.0.0.jar, jar org = org.apache.arrow, entry target = arrow-git.properties [error] Deduplicate found different file contents in the following: [error] Jar name = javax.inject-1.jar, jar org = javax.inject, entry target = javax/inject/Singleton.class [error] Jar name = jakarta.inject-2.6.1.jar, jar org = org.glassfish.hk2.external, entry target = javax/inject/Singleton.class [error] Deduplicate found different file contents in the following: [error] Jar name = protobuf-java-3.19.6.jar, jar org = com.google.protobuf, entry target = google/protobuf/duration.proto [error] Jar name = spark-core_2.12-3.5.0.jar, jar org = org.apache.spark, entry target = google/protobuf/duration.proto [error] Deduplicate found different file contents in the following: [error] Jar name = javax.inject-1.jar, jar org = javax.inject, entry target = javax/inject/Named.class [error] Jar name = jakarta.inject-2.6.1.jar, jar org = org.glassfish.hk2.external, entry target = javax/inject/Named.class [error] Deduplicate found different file contents in the following: [error] Jar name = javax.inject-1.jar, jar org = javax.inject, entry target = javax/inject/Inject.class [error] Jar name = jakarta.inject-2.6.1.jar, jar org = org.glassfish.hk2.external, entry target = javax/inject/Inject.class [error] Deduplicate found different file contents in the following: [error] Jar name = commons-logging-1.1.3.jar, jar org = commons-logging, entry target = org/apache/commons/logging/LogFactory.class [error] Jar name = jcl-over-slf4j-2.0.7.jar, jar org = org.slf4j, entry target = org/apache/commons/logging/LogFactory.class [error] Deduplicate found different file contents in the following: [error] Jar name = commons-logging-1.1.3.jar, jar org = commons-logging, entry target = org/apache/commons/logging/LogConfigurationException.class [error] Jar name = jcl-over-slf4j-2.0.7.jar, jar org = org.slf4j, entry target = org/apache/commons/logging/LogConfigurationException.class [error] Deduplicate found different file contents in the following: [error] Jar name = jakarta.annotation-api-1.3.5.jar, jar org = jakarta.annotation, entry target = javax/annotation/security/DenyAll.class [error] Jar name = jsr250-api-1.0.jar, jar org = javax.annotation, entry target = javax/annotation/security/DenyAll.class [error] Deduplicate found different file contents in the following: [error] Jar name = protobuf-java-3.19.6.jar, jar org = com.google.protobuf, entry target = google/protobuf/timestamp.proto [error] Jar name = spark-core_2.12-3.5.0.jar, jar org = org.apache.spark, entry target = google/protobuf/timestamp.proto [error] Deduplicate found different file contents in the following: [error] Jar name = jakarta.annotation-api-1.3.5.jar, jar org = jakarta.annotation, entry target = javax/annotation/Generated.class [error] Jar name = jsr250-api-1.0.jar, jar org = javax.annotation, entry target = javax/annotation/Generated.class [error] Deduplicate found different file contents in the following: [error] Jar name = protobuf-java-3.19.6.jar, jar org = com.google.protobuf, entry target = google/protobuf/source_context.proto [error] Jar name = spark-core_2.12-3.5.0.jar, jar org = org.apache.spark, entry target = google/protobuf/source_context.proto [error] Deduplicate found different file contents in the following: [error] Jar name = protobuf-java-3.19.6.jar, jar org = com.google.protobuf, entry target = google/protobuf/empty.proto [error] Jar name = spark-core_2.12-3.5.0.jar, jar org = org.apache.spark, entry target = google/protobuf/empty.proto [error] Deduplicate found different file contents in the following: [error] Jar name = jakarta.annotation-api-1.3.5.jar, jar org = jakarta.annotation, entry target = javax/annotation/Resource.class [error] Jar name = jsr250-api-1.0.jar, jar org = javax.annotation, entry target = javax/annotation/Resource.class [error] Deduplicate found different file contents in the following: [error] Jar name = jakarta.annotation-api-1.3.5.jar, jar org = jakarta.annotation, entry target = javax/annotation/security/RolesAllowed.class [error] Jar name = jsr250-api-1.0.jar, jar org = javax.annotation, entry target = javax/annotation/security/RolesAllowed.class [error] Deduplicate found different file contents in the following: [error] Jar name = jakarta.annotation-api-1.3.5.jar, jar org = jakarta.annotation, entry target = javax/annotation/PreDestroy.class [error] Jar name = jsr250-api-1.0.jar, jar org = javax.annotation, entry target = javax/annotation/PreDestroy.class [error] Deduplicate found different file contents in the following: [error] Jar name = protobuf-java-3.19.6.jar, jar org = com.google.protobuf, entry target = google/protobuf/descriptor.proto [error] Jar name = spark-core_2.12-3.5.0.jar, jar org = org.apache.spark, entry target = google/protobuf/descriptor.proto [error] Deduplicate found different file contents in the following: [error] Jar name = commons-logging-1.1.3.jar, jar org = commons-logging, entry target = org/apache/commons/logging/impl/SimpleLog.class [error] Jar name = jcl-over-slf4j-2.0.7.jar, jar org = org.slf4j, entry target = org/apache/commons/logging/impl/SimpleLog.class [error] Deduplicate found different file contents in the following: [error] Jar name = jakarta.annotation-api-1.3.5.jar, jar org = jakarta.annotation, entry target = javax/annotation/security/DeclareRoles.class [error] Jar name = jsr250-api-1.0.jar, jar org = javax.annotation, entry target = javax/annotation/security/DeclareRoles.class [error] Deduplicate found different file contents in the following: [error] Jar name = protobuf-java-3.19.6.jar, jar org = com.google.protobuf, entry target = google/protobuf/wrappers.proto [error] Jar name = spark-core_2.12-3.5.0.jar, jar org = org.apache.spark, entry target = google/protobuf/wrappers.proto [error] Deduplicate found different file contents in the following: [error] Jar name = javax.inject-1.jar, jar org = javax.inject, entry target = javax/inject/Qualifier.class [error] Jar name = jakarta.inject-2.6.1.jar, jar org = org.glassfish.hk2.external, entry target = javax/inject/Qualifier.class [error] Deduplicate found different file contents in the following: [error] Jar name = jakarta.annotation-api-1.3.5.jar, jar org = jakarta.annotation, entry target = javax/annotation/security/PermitAll.class [error] Jar name = jsr250-api-1.0.jar, jar org = javax.annotation, entry target = javax/annotation/security/PermitAll.class [error] Deduplicate found different file contents in the following: [error] Jar name = protobuf-java-3.19.6.jar, jar org = com.google.protobuf, entry target = google/protobuf/any.proto [error] Jar name = spark-core_2.12-3.5.0.jar, jar org = org.apache.spark, entry target = google/protobuf/any.proto [error] Deduplicate found different file contents in the following: [error] Jar name = jakarta.annotation-api-1.3.5.jar, jar org = jakarta.annotation, entry target = javax/annotation/Resources.class [error] Jar name = jsr250-api-1.0.jar, jar org = javax.annotation, entry target = javax/annotation/Resources.class [error] Deduplicate found different file contents in the following: [error] Jar name = jakarta.annotation-api-1.3.5.jar, jar org = jakarta.annotation, entry target = javax/annotation/Resource$AuthenticationType.class [error] Jar name = jsr250-api-1.0.jar, jar org = javax.annotation, entry target = javax/annotation/Resource$AuthenticationType.class [error] Deduplicate found different file contents in the following: [error] Jar name = jackson-core-2.15.2.jar, jar org = com.fasterxml.jackson.core, entry target = META-INF/versions/9/module-info.class [error] Jar name = jackson-databind-2.15.2.jar, jar org = com.fasterxml.jackson.core, entry target = META-INF/versions/9/module-info.class [error] Jar name = jackson-datatype-jsr310-2.13.4.jar, jar org = com.fasterxml.jackson.datatype, entry target = META-INF/versions/9/module-info.class [error] Jar name = gson-2.10.1.jar, jar org = com.google.code.gson, entry target = META-INF/versions/9/module-info.class [error] Jar name = log4j-api-2.20.0.jar, jar org = org.apache.logging.log4j, entry target = META-INF/versions/9/module-info.class [error] Jar name = parquet-jackson-1.12.3.jar, jar org = org.apache.parquet, entry target = META-INF/versions/9/module-info.class [error] Jar name = jcl-over-slf4j-2.0.7.jar, jar org = org.slf4j, entry target = META-INF/versions/9/module-info.class [error] Jar name = slf4j-api-2.0.7.jar, jar org = org.slf4j, entry target = META-INF/versions/9/module-info.class [error] Jar name = xz-1.9.jar, jar org = org.tukaani, entry target = META-INF/versions/9/module-info.class [error] Deduplicate found different file contents in the following: [error] Jar name = protobuf-java-3.19.6.jar, jar org = com.google.protobuf, entry target = google/protobuf/type.proto [error] Jar name = spark-core_2.12-3.5.0.jar, jar org = org.apache.spark, entry target = google/protobuf/type.proto [error] Deduplicate found different file contents in the following: [error] Jar name = jakarta.annotation-api-1.3.5.jar, jar org = jakarta.annotation, entry target = javax/annotation/PostConstruct.class [error] Jar name = jsr250-api-1.0.jar, jar org = javax.annotation, entry target = javax/annotation/PostConstruct.class [error] Deduplicate found different file contents in the following: [error] Jar name = netty-all-4.1.96.Final.jar, jar org = io.netty, entry target = META-INF/io.netty.versions.properties [error] Jar name = netty-buffer-4.1.96.Final.jar, jar org = io.netty, entry target = META-INF/io.netty.versions.properties [error] Jar name = netty-codec-http2-4.1.96.Final.jar, jar org = io.netty, entry target = META-INF/io.netty.versions.properties [error] Jar name = netty-codec-http-4.1.96.Final.jar, jar org = io.netty, entry target = META-INF/io.netty.versions.properties [error] Jar name = netty-codec-socks-4.1.96.Final.jar, jar org = io.netty, entry target = META-INF/io.netty.versions.properties [error] Jar name = netty-codec-4.1.96.Final.jar, jar org = io.netty, entry target = META-INF/io.netty.versions.properties [error] Jar name = netty-common-4.1.96.Final.jar, jar org = io.netty, entry target = META-INF/io.netty.versions.properties [error] Jar name = netty-handler-proxy-4.1.96.Final.jar, jar org = io.netty, entry target = META-INF/io.netty.versions.properties [error] Jar name = netty-handler-4.1.96.Final.jar, jar org = io.netty, entry target = META-INF/io.netty.versions.properties [error] Jar name = netty-resolver-4.1.96.Final.jar, jar org = io.netty, entry target = META-INF/io.netty.versions.properties [error] Jar name = netty-transport-classes-epoll-4.1.96.Final.jar, jar org = io.netty, entry target = META-INF/io.netty.versions.properties [error] Jar name = netty-transport-classes-kqueue-4.1.96.Final.jar, jar org = io.netty, entry target = META-INF/io.netty.versions.properties [error] Jar name = netty-transport-native-epoll-4.1.96.Final.jar, jar org = io.netty, entry target = META-INF/io.netty.versions.properties [error] Jar name = netty-transport-native-epoll-4.1.96.Final.jar, jar org = io.netty, entry target = META-INF/io.netty.versions.properties [error] Jar name = netty-transport-native-epoll-4.1.96.Final.jar, jar org = io.netty, entry target = META-INF/io.netty.versions.properties [error] Jar name = netty-transport-native-kqueue-4.1.96.Final.jar, jar org = io.netty, entry target = META-INF/io.netty.versions.properties [error] Jar name = netty-transport-native-kqueue-4.1.96.Final.jar, jar org = io.netty, entry target = META-INF/io.netty.versions.properties [error] Jar name = netty-transport-native-unix-common-4.1.96.Final.jar, jar org = io.netty, entry target = META-INF/io.netty.versions.properties [error] Jar name = netty-transport-4.1.96.Final.jar, jar org = io.netty, entry target = META-INF/io.netty.versions.properties [error] Deduplicate found different file contents in the following: [error] Jar name = javax.inject-1.jar, jar org = javax.inject, entry target = javax/inject/Scope.class [error] Jar name = jakarta.inject-2.6.1.jar, jar org = org.glassfish.hk2.external, entry target = javax/inject/Scope.class [error] Deduplicate found different file contents in the following: [error] Jar name = log4j-1.2-api-2.20.0.jar, jar org = org.apache.logging.log4j, entry target = META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat [error] Jar name = log4j-core-2.20.0.jar, jar org = org.apache.logging.log4j, entry target = META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat [error] Deduplicate found different file contents in the following: [error] Jar name = javax.inject-1.jar, jar org = javax.inject, entry target = javax/inject/Provider.class [error] Jar name = jakarta.inject-2.6.1.jar, jar org = org.glassfish.hk2.external, entry target = javax/inject/Provider.class [error] Deduplicate found different file contents in the following: [error] Jar name = jakarta.annotation-api-1.3.5.jar, jar org = jakarta.annotation, entry target = javax/annotation/security/RunAs.class [error] Jar name = jsr250-api-1.0.jar, jar org = javax.annotation, entry target = javax/annotation/security/RunAs.class [error] Total time: 5 s, completed 2025年7月12日 下午12:56:20 [error] server failed to start on local:sbt-server-8814d8f5c3747ce114fe. java.io.IOException: Could not create lock for \\.\pipe\sbt-server-8814d8f5c3747ce114fe_lock, error 5 sbt:spark-app>
07-13
package controller; import jakarta.servlet.http.HttpSession; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import pojo.UserForm; @Controller @RequestMapping("/user") public class UserControllerOrigin { //得到一个用来记录日志的对象,这样在打印信息时能够标记打印的是哪个类的信息 private static final Log logger = LogFactory.getLog(UserControllerOrigin.class); /** * 处理登录 * 使用UserForm 对象(实体 Bean)user接收登录页面提交的请求参数 */ @PostMapping("/login") public String login(UserForm user, HttpSession session, Model model) { if ("zhangsan".equals(user.getUname()) && "123456".equals(user.getUpass())) { session.setAttribute("u", user); logger.info("成功"); return "main"; } else { logger.info("失败"); //登录失败,跳转到login.jsp model.addAttribute("messageError", "用户名或密码错误"); return "login"; } } /** * 处理注册 * 使用UserForm对象(实体Bean)user接收注册页面提交的请求参数 */ @PostMapping("/register") public String register(UserForm user, Model model) { if (user.getUname() != null && !user.getUname().isEmpty() && user.getUpass() != null && !user.getUpass().isEmpty()) { logger.info("成功"); return "login"; } else { //注册失败,跳转到 register.jsp logger.info("失败"); //在register.jsp页面上可以使用EL表达式取出model的uname值 model.addAttribute("uname", user.getUname()); return "register";//返回 register.jsp } } }C:\Users\xx\Desktop\demo\src\main\java\controller\UserControllerOrigin.java:25:35 java: 找不到符号 符号: 方法 getUname() 位置: 类型为pojo.UserForm的变量 user
03-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值