Description of problem: While the use of ConsoleAppender in Log4J application logging configurations is discouraged, JBoss could probably do a better job of managing its use. Currently it's possible to encounter a deadlock if thread A invokes System.out.println() and thread B invokes Logger.info(). Thread A will get the lock on System.out (a java.io.PrintWriter), but then thread B will get the lock on the org.apache.log4j.ConsoleAppender. Then each thread is waiting on the other's lock.
Work around is to not use ConsoleAppenders in app log4js or them in async appender/handlers.
We'd have to fork the ConsoleAppender to make this work properly since each append invocation uses System.xxx.write(). We'd need to update it to capture System.out and System.err in a static variable to ensure it would work correctly.
If we don't want to go for a ConsoleAppender fork to resolve the deadlock, perhaps we can at least add a warn to notify that a deadlock is likely with the application level ConsoleAppender?
PR https://github.com/jboss-logging/log4j-jboss-logmanager/pull/10 MERGED.
Verified with EAP 6.4.2.CP.CR1 using attached reproducer.
Retroactively bulk-closing issues from released EAP 6.4 cumulative patches.