问题描述
因此,我一直在移植一些通过log4j上的logback使用的服务,并且我一直在使用log4j-over-SLF4J jar来欺骗我们的遗产依赖性.唯一的问题是log4j-over-slf4j并未实现许多log4j类,因此我看到一个不错的类别未从依赖罐中找到异常.人们如何解决这个问题?仅将NLOG4J放入您的类路径而不是log4j-over-over-slf4j jar是否足够?我还没有测试过最后一个想法,但明天我计划.
参考:
- http://www.slf4j.org/legacy.html
- http://www.slf4j.org/nlog4j/
推荐答案
唯一的问题是log4j-over-slf4j并未实现许多log4j类,因此我看到一个不错的类别从依赖罐中找不到例外.人们如何解决这个问题?
好吧,我想您正在 Bridging Legacy Apis apis 您发布的链接:
什么时候不起作用?
log4j-over-slf4j模块不会 应用程序调用log4j时工作 不存在的组件 桥.例如,应用程序 代码直接引用log4j 附录,过滤器或 然后 log4j-over-slf4j将是 log4j的替换不足. 但是,当配置log4j时 通过配置文件,无论是 log4j.properties或log4j.xml, log4j-over-slf4j模块应该只是 工作正常.
如果依赖的罐子在您的控制之下,您应该真正尝试使用 slf4j迁移器工具.
仅将NLOG4J放入您的类路径而不是log4j-over-over-slf4j jar?
是否足以
这可能会解决ClassNotFoundException,但我想知道整个记录将如何工作.鉴于 nlog4j 不再是积极发展的解决方案.
问题描述
So I've been porting some of our services to use Logback over log4j and I've been using the log4j-over-slf4j jar to spoof log4j for our legacy dependencies. The only issue is log4j-over-slf4j doesn't implement many of the classes of log4j so I'm seeing a decent few class not found exceptions from dependent jars. How have people got around this? Is it enough to just put the nlog4j in your classpath instead of the log4j-over-slf4j jar? I haven't tested this last idea yet but I'm planning on it tomorrow.
Reference:
推荐答案
The only issue is log4j-over-slf4j doesn't implement many of the classes of log4j so I'm seeing a decent few class not found exceptions from dependent jars. How have people got around this?
Well, I guess you're facing "problems" explicitly mentioned in the Bridging legacy APIs link you posted:
When does it not work?
The log4j-over-slf4j module will not work when the application calls log4j components that are not present in the bridge. For example, when application code directly references log4j appenders, filters or the PropertyConfigurator, then log4j-over-slf4j would be an insufficient replacement for log4j. However, when log4j is configured through a configuration file, be it log4j.properties or log4j.xml, the log4j-over-slf4j module should just work fine.
If the dependent JARs are under your control, you should really try to migrate the code using the SLF4J Migrator tool.
Is it enough to just put the nlog4j in your classpath instead of the log4j-over-slf4j jar?
This might solve the ClassNotFoundException but I wonder how the whole logging is going to work. And given that NLog4J is no longer actively developed, I wonder if this is a good long term solution.