2

如果有一种优雅的方法可以将 hybris 中的日志记录从 log4j 更改为 slf4j 或其他东西,我正在徘徊?

现在我在编写 java 代码时使用 slf4j,但 hybris 本身对任何生成的代码都使用 log4j。这导致在一个 hybris 扩展中使用混合日志框架。其实slf4j下面还是log4j,但是如果我想把log4j改成其他一些日志机制呢?

也许可以在一些配置文件中完成。有人已经这样做了吗?

4

1 回答 1

3

Depending on your current configuration, you can use a bridge between log4j and slf4j.1

Image from http://www.slf4j.org/legacy.html

In this way, you wouldn't need to modify the generated code. You can use a similar configuration if you use Log4J 2 as underlying logging framework.

See also Bridging legacy APIs in www.slf4j.org.


Notes

  1. Assuming you do not use log4j as underlying logging framework. Otherwise, this would result in an error stack.
  2. Image from http://www.slf4j.org/legacy.html
于 2014-11-13T17:53:58.187 回答