I'm using the Cargo Maven plugin to deploy a WAR to a remote server, and I'm having problems. I'll probably create a second question for that problem, but this one is about overriding a Maven plugin's log4j configuration. Cargo uses JBoss' client libraries to ship stuff to JBoss servers (which I'm trying to do.) The JBoss library uses log4j. Cargo doesn't set up any sort of mapping layer that I know of.
So, essentially, log messages are occurring in the dependent library of a Maven plugin. I tried setting -Dlog4j.debug and got this information:
log4j: Trying to find [log4j.xml] using ClassRealm[plugin>org.codehaus.cargo:cargo-maven2-plugin:1.0.5, parent: ClassRealm[maven.api, parent: null]] class loader. log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource(). log4j: Trying to find [log4j.properties] using context classloader ClassRealm[plugin>org.codehaus.cargo:cargo-maven2-plugin:1.0.5, parent: ClassRealm[maven.api, parent: null]]. log4j: Using URL [jar:file:/C:/Users/username/.m2/repository/org/jboss/jbossts/jbossjts/4.13.1.Final/jbossjts-4.13.1.Final.jar!/log4j.properties] for automatic log4j configuration. log4j: Reading configuration from URL jar:file:/C:/Users/username/.m2/repository/org/jboss/jbossts/jbossjts/4.13.1.Final/jbossjts-4.13.1.Final.jar!/log4j.properties log4j: Could not find root logger information. Is this OK? log4j: Parsing for [com.arjuna] with value=[INFO, default, stdout]. log4j: Level token is [INFO]. log4j: Category com.arjuna set to INFO log4j: Parsing appender named "default". log4j: Parsing layout options for "default". log4j: Setting property [conversionPattern] to [%d [%t] %-5p %c - %m%n]. log4j: End of parsing for "default". log4j: Setting property [maxBackupIndex] to [2]. log4j: Setting property [file] to [transaction.log]. log4j: Setting property [maxFileSize] to [500KB]. log4j: setFile called: transaction.log, true log4j: setFile ended log4j: Parsed "default" options. log4j: Parsing appender named "stdout". log4j: Parsing layout options for "stdout". log4j: Setting property [conversionPattern] to [%d [%t] %-5p %c - %m%n]. log4j: End of parsing for "stdout". log4j: Setting property [threshold] to [WARN]. log4j: Parsed "stdout" options. log4j: Handling log4j.additivity.com.arjuna=[null] log4j: Finished configuring. log4j:WARN No appenders could be found for logger (org.jnp.interfaces.TimedSocketFactory). log4j:WARN Please initialize the log4j system properly.
Then I tried setting -Dlog4j.configuration=mylog4j.properties but got this:
log4j: Trying to find [mylog4j.properties] using context classloader ClassRealm[plugin>org.codehaus.cargo:cargo-maven2-plugin:1.0.5, parent: ClassRealm[maven.api, parent: null]]. log4j: Trying to find [mylog4j.properties] using ClassRealm[plugin>org.codehaus.cargo:cargo-maven2-plugin:1.0.5, parent: ClassRealm[maven.api, parent: null]] class loader. log4j: Trying to find [mylog4j.properties] using ClassLoader.getSystemResource(). log4j: Could not find resource: [mylog4j.properties]. log4j:WARN No appenders could be found for logger (org.jnp.interfaces.TimedSocketFactory). log4j:WARN Please initialize the log4j system properly.
It would appear that the log4j configuration file needs to be in the Maven plugin's classpath, but I don't know how to include random files there, only dependencies. I really want to set this information so that I can get debug information from the JBoss libraries in order to troubleshoot my problem.