From 8ba9e5bede083864bd34b3cd9f49528f13cdebeb Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Sun, 9 Nov 2014 15:41:15 +0100 Subject: [PATCH] Add logLevel property to enable different log levels for the examples. Motivation: When running the examples using the provided run-examples.sh script the log level is 'info' level. It can be handy to be able to configure a different level, for example 'debug', while learning and trying out the the examples. Modifications: Added a dependency to logback-classic to the examples pom.xml, and also added a logback configuration file. The log level can be configured by setting the 'logLevel' system property, and if that property is not set the default will be 'info' level. The run-examples.sh was updated to show an example of using the system property to set the log level to 'debug' Result: It is now possible to turn on debug logging by settnig a system property on the command line. --- example/pom.xml | 5 +++++ example/src/main/resources/logback.xml | 11 +++++++++++ run-example.sh | 1 + 3 files changed, 17 insertions(+) create mode 100644 example/src/main/resources/logback.xml diff --git a/example/pom.xml b/example/pom.xml index eeb1aed1b9..dd993c00f0 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -109,6 +109,11 @@ netty-transport-rxtx ${project.version} + + ch.qos.logback + logback-classic + runtime + diff --git a/example/src/main/resources/logback.xml b/example/src/main/resources/logback.xml new file mode 100644 index 0000000000..ea5238ed68 --- /dev/null +++ b/example/src/main/resources/logback.xml @@ -0,0 +1,11 @@ + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + diff --git a/run-example.sh b/run-example.sh index b931bab17b..2e8f972bf6 100755 --- a/run-example.sh +++ b/run-example.sh @@ -66,6 +66,7 @@ if [[ -z "$EXAMPLE" ]] || [[ -z "$EXAMPLE_CLASS" ]] || [[ $# -ne 0 ]]; then echo " Usage: $0 [-D[=] ...] " >&2 echo "Example: $0 -Dport=8443 -Dssl http-server" >&2 echo " $0 -Dhost=127.0.0.1 -Dport=8009 echo-client" >&2 + echo " $0 -DlogLevel=debug -Dhost=127.0.0.1 -Dport=8009 echo-client" >&2 echo >&2 echo "Available examples:" >&2 echo >&2