So I've been trying to use a custom log4j.xml in my ear application on JBoss EAP 6.1. I've found that if I use a file appender and a straight static filename, it will log to that file as I expect (using log4j2.xml in my war in this case, but it does the same thing if I use log4j.xml with log4j 1.2):
<?xml version="1.0" encoding="UTF-8" ?>
<Configuration status="debug">
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n" />
</Console>
<File name="A1" fileName="server.log">
<PatternLayout pattern="%t %-5p %c{2} - %m%n" />
</File>
</Appenders>
<Loggers>
<Logger name="com.xxx.yyy" level="debug" additivity="false">
<AppenderRef ref="A1" />
</Logger>
</Loggers>
</Configuration>
But this will cause it to log to [jboss-eap]/bin/server.log. I can put in substitution variables to point it to a file under the jboss log directory (in the eap case, [jboss-eap]/standalone/log/test.log):
<?xml version="1.0" encoding="UTF-8" ?>
<Configuration status="debug">
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n" />
</Console>
<File name="A1" fileName="${sys:jboss.server.log.dir}/test.log">
<PatternLayout pattern="%t %-5p %c{2} - %m%n" />
</File>
</Appenders>
<Loggers>
<Logger name="com.xxx.yyy" level="debug" additivity="false">
<AppenderRef ref="A1" />
</Logger>
</Loggers>
</Configuration>
and I can see that it is doing the substitution for me:
16:16:28,626 INFO [stdout] (ServerService Thread Pool -- 71) 2014-10-30 16:16:28,626
DEBUG Starting FileManager C:\Users\xxxxxx\Apps\jbossdevstudio\runtimes\jboss-
eap\standalone\log/test.log
And output will actually show up in test.log. But what I really want is to just have the logging go into the standard server.log. If I try the above substitutions but use server.log instead of test.log, nothing actually gets logged. The other thing I've tried is using the console appender, but then I get really long output lines that log the timestamp twice and have two log level indicators:
16:24:08,038 INFO [stdout] (http-/0.0.0.0:8080-1) 2014-10-30 16:24:08,036 INFO
[http-/0.0.0.0:8080-1] com.xxx.TestServlet (TestServlet.java:25) - This is a test
When what I really want is just:
2014-10-30 16:24:08,036 INFO [http-/0.0.0.0:8080-1] com.xxx.TestServlet
(TestServlet.java:25) - This is a test
So I'm not sure how to do this. We could configure the jboss internal logging configuration, but in our organization, changing such things within the server involves our middleware team, and we'd rather just change a custom log4j.xml if we need to adjust the log level on certain classes. We can live with the longer output if necessary, but we also use Splunk, and I believe that it will get confused on the log level of the stdout output instead of what we actually were logging at when trying to filter the logs by log level.
I would appreciate any advice that folks have.