-
1. Re: Log4j2 support for wildfly
jamezp Jul 21, 2016 1:16 PM (in response to nick.sree)I don't know how contexts are determined in log4j2, but I'd assume it's easiest to include log4j2 in your deployment. Essentially like you're doing in your second option. Using a module may be problematic if each deployment has it's own configuration as one deployment would win with regards to the log manager configuration.
The console logging can be a bit tricky. Because WildFly wraps both System.out and System.err in loggers anything written to those streams will go through the servers log manager. One option around this is to use your own ConsoleAppender that doesn't writ directly to System.out or System.err. You can use the FileDescriptor and PrintStream instead like is do in the forked version of log4j provided by WildFly.
Your other option is to define a new console-handler on WildFly that just uses a pattern of %s. Then add a logger for stdout and/or stderr and add the handler to each logger. The following CLI commands should give you the desired outcome.
/subsystem=logging/pattern-formatter=PLAIN:add(pattern="%s%n") /subsystem=logging/console-handler=streams:add(autoflush=true, named-formatter=PLAIN, target=System.out) /subsystem=logging/logger=stdout:add(handlers=[streams], use-parent-handlers=false)
--
James R. Perkins