spring - Log4jConfigurer 无法解析
问题描述
我正在从 spring 版本 4 迁移到 spring 版本 5。在 org.springframework.utils.Log4jConfigurer 中出现错误。
错误是:无法解析符号 Log4jConfigurer
还尝试将 apache Log4j 版本更改为 2,但错误仍然存在。Spring 5 中 Log4jConfigurer 的替代方案是什么?任何帮助。
我使用的是 Spring 4.XX 并使用以下设置来配置 Log4j。现在将其升级到 Spring 5.0.2,其中 Log4jConfigurer 类已被删除。我如何在 Spring 5.0.2 中做到这一点?
<bean
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetClass" value="org.springframework.util.Log4jConfigurer"/>
<property name="targetMethod" value="initLogging"/>
<property name="arguments">
<list>
<value>classpath:mylog4j.properties</value>
</list>
</property>
</bean>
解决方案
您不必定义 Log4JConfigurer。只需将 log4j.properties 添加到您的类路径即可配置 log4j。Spring 5 会找到它,您可以使用 Log4J。关于 Log4j 的版本,我在 Spring 5 项目中使用的是 1.2.17 版本,它运行良好。
推荐阅读
- c - 如何将两个图像与c进行比较
- python - 使用 sort_values() 函数后按升序对 Pandas 系列进行排序
- azure-functions - SeriveBusTrigger 的持久客户端未调用 Orchestrator
- node.js - Express 在该操作发生所有事情后记录资源使用情况
- spring - 在旧版应用程序中用 Thymeleaf 替换 JSP
- typescript - 错误 React Native with Expo, Navigation ''navigation.navigate is not a function"
- javascript - 格式化数据以在 Angular 材料表中使用
- c# - 为要从视图传递到控制器的特定 json 创建一个类
- database - 在 Redis 中创建数据库
- mysql - Mysql我们可以使用SELECT IN查询获取所有行吗