-
1. How to include log4j in Arquillian tests?
bcn Apr 15, 2011 9:21 AM (in response to bcn)By the way, it would be nice to be able to check the generated test.war for if the resources are included correctly. But since it is undeployed after the test, it disappears immediately.
-
2. How to include log4j in Arquillian tests?
mwtemple Apr 15, 2011 10:11 AM (in response to bcn)As long as the src/test/resources directory is in the classpath, you need the following VM argument:
-Dlog4j.configuration=log4j.properties
-
3. How to include log4j in Arquillian tests?
mwtemple Apr 15, 2011 10:13 AM (in response to bcn)1 of 1 people found this helpfulAfter you build the archive, send this to sysout:
archive.toString(Formatters.VERBOSE)
-
4. Re: How to include log4j in Arquillian tests?
bcn Apr 15, 2011 10:59 AM (in response to mwtemple)Thank you for the answers.
Ok archive.toString lets you see the structure, although not check the real test.war.
Is there an option to tell Arquillian not to undeploy the test.war after the test? Or to drop the file in another location?
The VM argument didn't do any effect. The output folder of src/test/resources is target/test-classes.
I hope I understand correctly what you mean.
I run the test in Eclipse, Run Configurations, Maven Build with goal test.There, you cannot control the class path explicitly. I guess Maven takes care of it, right? In the JRE tab I add the argument.
Where is the log file supposed to appear if I use a simple appender file name without path? In the base directory of the run? Or in a JBoss folder?
Thanks in advance,
Ulrich
-
5. How to include log4j in Arquillian tests?
mwtemple Apr 15, 2011 11:48 AM (in response to bcn)I would start by seeing where it is picking up the log4j.properties from.
Add this to your VM arguments:
-Dlog4j.debug=true
Watch in the console of the JUnit/TestNG run and see if it is using your log4j.properties.
If not, I would get that right first.
-
6. Re: How to include log4j in Arquillian tests?
bcn Apr 15, 2011 1:59 PM (in response to mwtemple)I have found that the log messages are all written to the jboss server.log.
If I explicitly initialize log4j in the test:
PropertyConfigurator.configure("log4j.properties");
Logger log = Logger.getLogger(EstabTypeTest.class);
System.out.println("log: "+log);
log.debug("starting test");
I get in the jboss console:
19:21:07,480 ERROR [STDERR] log4j:ERROR Could not read configuration file [log4j.properties].
19:21:07,480 ERROR [STDERR] java.io.FileNotFoundException: log4j.properties (El sistema no puede encontrar el archivo especificado)
19:21:07,481 ERROR [STDERR] at java.io.FileInputStream.open(Native Method)
19:21:07,481 ERROR [STDERR] at java.io.FileInputStream.<init>(FileInputStream.java:106)
19:21:07,481 ERROR [STDERR] at java.io.FileInputStream.<init>(FileInputStream.java:66)
19:21:07,481 ERROR [STDERR] at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:306)
...
19:21:07,502 ERROR [STDERR] log4j:ERROR Ignoring configuration file [log4j.properties].
19:21:07,503 INFO [STDOUT] log: org.jboss.logmanager.log4j.BridgeLogger@5a90f357
Although log4j.properties is in target/test-classes and I can see in the Maven debug output that the folder is added to the class-path.
[DEBUG] Test Classpath :
[DEBUG] xxx\target\test-classes
The path is also in the manifest of the surefire jar file in target/surefire.
On other hand, if I put the absolute path in PropertyConfigurator.configure(), then the file is created. But all messages are nevertheless written to the jboss.log.
Thanks,
Ulrich
-
7. Re: How to include log4j in Arquillian tests?
mwtemple Apr 16, 2011 12:10 AM (in response to bcn)1 of 1 people found this helpfulThere is JUnit/TestNG logging (where you can see output from arquillian bundling, deploying, method invocation, undeploying...).
VM Arguments:
-Dlog4j.configuration=log4j.properties
-Dlog4j.debug=true
There is JBoss logging (where you can see output from within the @test methods).
I don't bundle anything in the test.jar for logging.
Edit server\default\deploy\jboss-logging.xml and change the console level to whatever you want (requires JBoss restart).
Then in your class, do this:
import org.jboss.logging.Logger;
private static Logger logger = Logger.getLogger(YourTestClass.class);
logger.info("this will go to the Jboss console if the level is set correctly");
Let me know if that helps...
Mark
-
8. How to include log4j in Arquillian tests?
bcn Apr 18, 2011 4:38 AM (in response to mwtemple)Ok that works, but what I really want is writing the log to my own log file. I found how to do it, but hit this known bug:
https://issues.jboss.org/browse/JBLOGGING-56
So let's wait until this is fixed.
Thanks,
Ulrich