I can now answer my own question:

There is a slightly hackish but very effective way to consistently use SLF4J and logback with Pax Exam and to stay clear of Pax Logging, log4j and JCL used in the default setup.

1) Create a file META-INF/links/org.ops4j.pax.logging.api.link in the classpath of your project containing this line:

mvn:org.slf4j/slf4j-api/1.6.1

By doing so, you fool Pax Exam into provisioning SLF4J instead of Pax Logging.

2) Add the following options to your tests:
mavenBundle("ch.qos.logback", "logback-core", "0.9.29"),
mavenBundle("ch.qos.logback", "logback-classic", "0.9.29"),

This takes care of logging inside the test container.

3) Add the following dependencies to your POM

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>0.9.29</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>0.9.29</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>1.6.1</version>
        </dependency>

This takes care of logging outside the test container. The last one is only required for the Pax Runner Container.

This is not yet the solution for http://team.ops4j.org/browse/PAXEXAM-252, but a viable workaround for the current release.

Best regards,
Harald

Am 31.07.2011 10:07, schrieb Harald Wellmann:
Hi Andreas,

yes, removing slf4j would solve the conflict but not the problem that I
can't use logback with Pax Exam.

 From a recent discussion on this list, I understood that Pax Logging
emulates various logging APIs including SLF4J and redirects all log
events to an embedded log4j backend which is hard to configure and
cannot be exchanged by logback or other backends.

So currently, some of my log messages are logged via logback, which is
what I want, while some others are logged via log4j which is caused by
Pax Logging provisioned by Pax Exam.

As I said earlier, Pax Logging seems to solve problems I've never had,
and I don't find it useful. Unlike Pax Exam which is very useful, and
even more so if it didn't force its own choice of logging on me.

If Pax Logging continues to be the default used by Pax Exam, there
should be an option to turn this off and let the user provision their
own logging bundles.

And I wonder if there's any workaround in the current version to force
Pax Exam not to provision Pax Logging, short of hacking the sources.

Best regards,
Harald

_______________________________________________
general mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/general

Reply via email to