karaf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steinar Bang ...@dod.no>
Subject Re: How to get the karaf.log logging in a pax exam test with the karaf container?
Date Fri, 07 Jul 2017 07:37:03 GMT
>>>>> Steinar Bang <sb@dod.no>:

>>>>> Jean-Baptiste Onofré <jb@nanthrax.net>:
>> you can take about what we do in itest:

>> https://github.com/apache/karaf/blob/master/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java

>> You can see that we override the default pax-logging configuration
>> with our own file:

>> replaceConfigurationFile("etc/org.ops4j.pax.logging.cfg",
>> getConfigFile("/etc/org.ops4j.pax.logging.cfg")),

> Thanks! That worked!

> Here's what I did
>  1. Copied the above code into the pax exam setup options
>  2. Copied the getConfigFile() method from the KarafTestSupport.java
>     file into my pax exam test
>      https://github.com/apache/karaf/blob/master/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java#L174
>  3. Copied the config file from the karaf test into
>     src/test/resources/etc in my pax exam project
>      https://github.com/apache/karaf/blob/master/itests/src/test/resources/etc/org.ops4j.pax.logging.cfg

I forgot one thing:
 4. Add keepRuntimeFolder() to the configuration options:

> Then the resulting karaf.log file ended up as
>  target/exam/<uuid>/data/log/karaf.log

Note that if keepRuntimeFolder() isn't set, the runtime is cleaned up at
the end of the test, and karaf.log is gone.

View raw message