Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b5SFkZoaMCukJNvZCV
41 lines
2.1 KiB
Bash
Executable File
41 lines
2.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Transcripts 11 and 12: what happens when Logback and Log4j2 are both on the classpath, and the
|
|
# dependency tree of the working build next to the broken one.
|
|
set -uo pipefail
|
|
source "$(dirname "$0")/lib.sh"
|
|
mkdir -p output
|
|
[ -f "$JAR" ] || mvn -B -q package -DskipTests
|
|
mvn -B -q -f broken/pom.xml package -DskipTests 2>&1 | grep -E 'ERROR|BUILD' | head -5
|
|
|
|
{
|
|
echo "# the same sources and the same dependencies as the module, minus the <exclusions> on spring-boot-starter-logging"
|
|
echo "\$ java -jar broken/target/log4j2-levels-both-logging-1.0.0.jar"
|
|
java -jar broken/target/log4j2-levels-both-logging-1.0.0.jar --server.port=18097 > /tmp/l4j-both.log 2>&1 &
|
|
BOTH=$!
|
|
for _ in $(seq 1 30); do kill -0 "$BOTH" 2>/dev/null || break; sleep 1; done
|
|
if kill -0 "$BOTH" 2>/dev/null; then
|
|
echo "(still running after 30 s: the application started)"
|
|
echo "\$ curl 'localhost:18097/demo/log?name=com.ankurm.log4j2levels.service.Probe' (the XML sets this package to DEBUG)"
|
|
curl -s --noproxy '*' "localhost:18097/demo/log?name=com.ankurm.log4j2levels.service.Probe" ; echo
|
|
echo "\$ curl localhost:18097/actuator/loggers/com.ankurm.log4j2levels.service"
|
|
curl -s --noproxy '*' "localhost:18097/actuator/loggers/com.ankurm.log4j2levels.service" ; echo
|
|
kill "$BOTH"; wait "$BOTH" 2>/dev/null
|
|
else
|
|
wait "$BOTH"; echo "exit code: $?"
|
|
fi
|
|
echo; echo '# what the application printed (SLF4J startup notes, then the lines from the request above)'
|
|
grep -E 'SLF4J|Probe' /tmp/l4j-both.log
|
|
} > output/11-both-logging.txt 2>&1
|
|
|
|
{
|
|
FILTER='org.apache.logging.log4j,ch.qos.logback,org.slf4j'
|
|
echo "# mvn dependency:tree for the module (Log4j2 only)"
|
|
mvn -B -f pom.xml dependency:tree -Dincludes="$FILTER" -DoutputFile=/tmp/l4j-tree-good.txt > /dev/null 2>&1
|
|
sed 's/^/ /' /tmp/l4j-tree-good.txt
|
|
echo
|
|
echo "# mvn dependency:tree for broken/pom.xml (exclusions removed)"
|
|
mvn -B -f broken/pom.xml dependency:tree -Dincludes="$FILTER" -DoutputFile=/tmp/l4j-tree-bad.txt > /dev/null 2>&1
|
|
sed 's/^/ /' /tmp/l4j-tree-bad.txt
|
|
} > output/12-dependency-tree.txt 2>&1
|
|
echo "wrote output/11-both-logging.txt and output/12-dependency-tree.txt"
|