Here is my current log4j settings file. Are these settings ideal for production use or is there something I should remove/tweak or change? I ask because I was getting all my
Log4j 1.2 is vulnerable to deadlocks when toString()
produces nested logging.
See old aged still unresolved issues like Log4J can create deadlock conditions (concurrent package donation) and Deadlock with RollingFileAppender.
It also has performance-killing lock synchronization issues under heavy concurrent load. Like Category callAppenders synchronization causes java.lang.Thread.State: BLOCKED and Move org.apache.log4j.Category to reentrant read/write locks.
Even AsyncAppender is not free of excessive locks: AsyncAppender.doAppend() does not need to be synchronized and Deadlock in 1.2.15 caused by AsyncAppender and ThrowableInformation classes. Also beware of AsyncAppender overflow.
One caveat is to always constrain root category level to at least INFO or higher. This would prevent logging calls from acquiring unnecessary locks mentioned in the above issues. Just limiting appender threshold is not sufficient as it is taken into account later. See explanation with publish/subscribe analogy:
To answer your question about how threshold interacts with category, basically think of it is as a publish/subscribe. The category sets what is published by the logger, the threshold sets the subscription level of the appender.
Nested categories of interest can be individually given lower priorities if needed.
This looks normal. I don't see how this alone could cause log4j blocking. Maybe you could post a thread dump of your issue?
%F:%L has serious performance impact. Although I don't see how they'd cause locking, I'd consider omitting them for production.
Are you creating a Logger for each class using the standard private static final Logger logger = Logger.getLogger(Foo.class);
where Foo is the class in which the logger is declared? If you only have 1 Logger instance in your entire application, there could be some contention if there is a lot of logging.