Saša
Saša

Reputation: 4798

replace log4j with slf4j in hybris

I am wandering if there is an elegant way to change logging in hybris from log4j to slf4j or something else?

Right now I am using slf4j when writing java code, but hybris itself is using log4j for any generated code. That is causing to use mixed logging frameworks in one hybris extension. Actually it is still log4j underneath the slf4j, but what if I want to change log4j to some other logging mechanism?

Maybe it can be done in some configuration file. Has anybody done that already?

Upvotes: 2

Views: 1161

Answers (1)

Paul Vargas
Paul Vargas

Reputation: 42020

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

Upvotes: 3

Related Questions