The trouble with doing this based on test metadata is that all tests are run in a single JVM instance, and modifying the Log4j configuration on the fly within a JVM is not exactly easy. Instead, I would set up profiles in your project.clj
to disable the :benchmark
tests by default, and set up a separate profile for running benchmarks. Assuming that you have your :resource-paths
set up to include a debug-level log4j.properties
file, your benchmark profile could then set up the classpath or system profiles as appropriate to use a different file. For example:
(defproject myproject
...
:test-selectors {:default (complement :benchmark)}
:profiles {
:benchmark {
:test-selectors {:default :benchmark}
:jvm-opts ["-Dlog4j.configuration=log4j-benchmark.properties"]
}
})
You could then run the benchmarks with:
> lein with-profile +benchmark test