From c5aacab41c86851fefa2b325453badbf0c01758e Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Thu, 21 Nov 2024 12:47:47 +0100 Subject: [PATCH] Add log4j logging (#383) Enables java logging. The log level can be changed by setting a variable. Set and run like this: export JAVA_OPTS="-Dorg.metafacture.metafix.logLevel=DEBUG"; ./gradlew installDist; cd metafix-runner/build/install/metafix-runner; bin/metafix-runner $pathTo.flux Note that you cannot use `./gradlew :metafix-runner:run ...` as setting the log level only works within the distribution. Co-authored-by: Jens Wille --- README.md | 6 ++++++ metafix-runner/build.gradle | 6 +++++- metafix/src/main/resources/log4j.xml | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 metafix/src/main/resources/log4j.xml diff --git a/README.md b/README.md index bbdfa2c2..d03f9946 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,12 @@ To execute a Fix (embedded in a Flux) via CLI: `./gradlew :metafix-runner:run --args="$PWD/path/to.flux"` +To execute a Fix (embedded in a Flux) via CLI in java debug mode: +make sure to pipe to `log-stream` after your `fix` command in flux resp. make +use of `log-object` at the proper location. Then: + +`export JAVA_OPTS="-Dorg.metafacture.metafix.logLevel=DEBUG"; ./gradlew installDist; cd metafix-runner/build/install/metafix-runner; bin/metafix-runner "$PWD/path/to.flux"` + (To import the projects in Eclipse, choose `File > Import > Existing Gradle Project` and select the `metafacture-fix` directory.) ## Usage diff --git a/metafix-runner/build.gradle b/metafix-runner/build.gradle index 1179b5c9..ab71abb7 100644 --- a/metafix-runner/build.gradle +++ b/metafix-runner/build.gradle @@ -39,11 +39,15 @@ dependencies { application { mainClass = 'org.metafacture.runner.Flux' + applicationDefaultJvmArgs = [ + "-Dorg.metafacture.metafix.logLevel=INFO" + ] + if (project.hasProperty('profile')) { def file = project.getProperty('profile') ?: project.name def depth = project.hasProperty('profile.depth') ? project.getProperty('profile.depth') : 8 - applicationDefaultJvmArgs = [ + applicationDefaultJvmArgs += [ "-XX:FlightRecorderOptions=stackdepth=${depth}", "-XX:StartFlightRecording=dumponexit=true,filename=${file}.jfr,settings=profile" ] diff --git a/metafix/src/main/resources/log4j.xml b/metafix/src/main/resources/log4j.xml new file mode 100644 index 00000000..81f3a9e5 --- /dev/null +++ b/metafix/src/main/resources/log4j.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + +