Hi all,
I have a little question how to use slf4j correctly. We use SLF4J as logging frontend in a framework. There are lots of classes that contain business logic. These classes are initialized once. Here we have the following signature for the loggers "private final Logger logger = LoggerFactory.getLogger(MyClass.class);". On the other hand there are a lot of domain classes. In a productive environment it is possible that there are 10'000 or 100'000s of domain classes. The domain classes also have to log stuff. I think there it won't be a good idea to have the logger static. But then the drawbacks of static occur (not ioc friendly, unknown behavior because the logger is JVM wide the same). We thought about the following solution but are not sure if SLF4J can be used like that : All business-logic classes that are initialized once get the logger like written above :"private final Logger logger = LoggerFactory.getLogger(MyClass.class);". The domain classes are created through a factory. In this factory we have a call like "private final Logger logger = MySingletonLoggerFactory.getLogger(MyDomainClass.class) ;" The MySingletonLoggerFactory class then is responsible of returning the same logger for each type of domain object. What do you think about the solution? Is this a feasible way ? Are there better ways to go? I am really looking forward to hearing from you. Regards, Florian
_______________________________________________ user mailing list [email protected] http://www.slf4j.org/mailman/listinfo/user
