At the moment, I'm working with
- log4j 2.7;
- springframework 4.3.5;
- hibernate 5.2.3.
I configure log4j via an xml file.
To do this, I created some appenders, one of which is named "General".
What I need is that all logs must go to that appender (included the ones generated by springframework or hibernate) and that none of the latter are printed on the console (I still need for other log from other classes).
I tried writing these Loggers:
<Loggers>
<Logger name="org" level="ALL" />
<Root level="ALL" additivity="false">
<AppenderRef ref="General"/>
</Root>
<Logger name="tests" level="ALL" additivity="false">
<AppenderRef ref="console"/>
<AppenderRef ref="General"/>
</Logger>
</Loggers>
The point is that while all the packages but springframework are correctly logging via that appender, springframework still logs on console and does not write any line via the "General" appender. How can I fix that?
EDIT: I found out that it can be due to the fact that springframework seems to log using other libraries (logback, slf4j and similar). I also read that springboot can be configured to use log4j and, since I still don't know much about Spring and its libraries, I don't know how to get the result I want.
logger
, notLogger
) , also there is a dash in<appender-ref>
– Fabien Benoit-Koch