From 57f7f2587d9008bb0068b9cf175b668a73ee973e Mon Sep 17 00:00:00 2001 From: amckenzie Date: Thu, 17 Oct 2019 08:53:45 +0100 Subject: [PATCH] Fix log4j error messages when app is run --- runSystemCommand.sh | 2 +- .../command/client/jmx/CommandChecker.java | 10 +++++----- src/main/resources/log4j.xml | 19 +++++++++++++++++++ src/main/resources/log4j2.xml | 15 --------------- .../client/jmx/CommandCheckerTest.java | 4 ++-- 5 files changed, 27 insertions(+), 23 deletions(-) create mode 100644 src/main/resources/log4j.xml delete mode 100644 src/main/resources/log4j2.xml diff --git a/runSystemCommand.sh b/runSystemCommand.sh index 8a989be..d404ec2 100755 --- a/runSystemCommand.sh +++ b/runSystemCommand.sh @@ -11,7 +11,7 @@ # ################################################ -FRAMEWORK_JMX_COMMAND_CLIENT_VERSION=2.2.1-SNAPSHOT +FRAMEWORK_JMX_COMMAND_CLIENT_VERSION=2.2.2-SNAPSHOT CONTEXT_NAME="people" USER_NAME="admin" PASSWORD="admin" diff --git a/src/main/java/uk/gov/justice/framework/command/client/jmx/CommandChecker.java b/src/main/java/uk/gov/justice/framework/command/client/jmx/CommandChecker.java index a364448..9420059 100644 --- a/src/main/java/uk/gov/justice/framework/command/client/jmx/CommandChecker.java +++ b/src/main/java/uk/gov/justice/framework/command/client/jmx/CommandChecker.java @@ -2,7 +2,7 @@ import static java.lang.String.format; import static java.time.Duration.between; -import static org.apache.commons.lang3.time.DurationFormatUtils.formatDurationHMS; +import static org.apache.commons.lang3.time.DurationFormatUtils.formatDuration; import static uk.gov.justice.services.jmx.api.domain.CommandState.COMMAND_COMPLETE; import static uk.gov.justice.services.jmx.api.domain.CommandState.COMMAND_FAILED; @@ -37,22 +37,22 @@ public boolean commandComplete(final SystemCommanderMBean systemCommanderMBean, final ZonedDateTime endTime = clock.now(); final long durationMillis = between(startTime, endTime).toMillis(); - final String duration = formatDurationHMS(durationMillis); + final String duration = formatDuration(durationMillis, "HH:mm:ss"); toConsolePrinter.println(format("Command %s complete", commandStatus.getSystemCommandName())); - toConsolePrinter.println(format("%s duration %s (hours:minutes:seconds:milliseconds)", commandStatus.getSystemCommandName(), duration)); + toConsolePrinter.println(format("%s duration %s (hours:minutes:seconds)", commandStatus.getSystemCommandName(), duration)); return true; } if(commandState == COMMAND_FAILED) { final long durationMillis = between(startTime, clock.now()).toMillis(); - final String duration = formatDurationHMS(durationMillis); + final String duration = formatDuration(durationMillis, "HH:mm:ss"); final String errorMessage = commandStatus.getMessage(); final String systemCommandName = commandStatus.getSystemCommandName(); toConsolePrinter.println(format("ERROR: Command %s failed", systemCommandName)); toConsolePrinter.println(format("ERROR: %s", errorMessage)); - toConsolePrinter.println(format("%s duration %s (hours:minutes:seconds:milliseconds)", commandStatus.getSystemCommandName(), duration)); + toConsolePrinter.println(format("%s duration %s (hours:minutes:seconds)", commandStatus.getSystemCommandName(), duration)); throw new SystemCommandFailedException(format("Comand %s failed. %s", systemCommandName, errorMessage)); } diff --git a/src/main/resources/log4j.xml b/src/main/resources/log4j.xml new file mode 100644 index 0000000..f702d3c --- /dev/null +++ b/src/main/resources/log4j.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml deleted file mode 100644 index 17fecc4..0000000 --- a/src/main/resources/log4j2.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/test/java/uk/gov/justice/framework/command/client/jmx/CommandCheckerTest.java b/src/test/java/uk/gov/justice/framework/command/client/jmx/CommandCheckerTest.java index dbc9c3c..0f2125d 100644 --- a/src/test/java/uk/gov/justice/framework/command/client/jmx/CommandCheckerTest.java +++ b/src/test/java/uk/gov/justice/framework/command/client/jmx/CommandCheckerTest.java @@ -57,7 +57,7 @@ public void shouldLogAndReturnTrueIfTheCommandIsComplete() throws Exception { assertThat(commandChecker.commandComplete(systemCommanderMBean, commandId, startTime), is(true)); verify(toConsolePrinter).println("Command CATCHUP complete"); - verify(toConsolePrinter).println("CATCHUP duration 01:23:00.000 (hours:minutes:seconds:milliseconds)"); + verify(toConsolePrinter).println("CATCHUP duration 01:23:00 (hours:minutes:seconds)"); } @Test @@ -88,7 +88,7 @@ public void shouldLogAndThrowExceptionfTheCommandFails() throws Exception { verify(toConsolePrinter).println("ERROR: Command CATCHUP failed"); verify(toConsolePrinter).println("ERROR: CATCHUP failed with 23 errors"); - verify(toConsolePrinter).println("CATCHUP duration 01:23:00.000 (hours:minutes:seconds:milliseconds)"); + verify(toConsolePrinter).println("CATCHUP duration 01:23:00 (hours:minutes:seconds)"); } @Test