Skip to content

Commit 1025245

Browse files
danbevtrustin
authored andcommitted
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.
1 parent dc9ca1a commit 1025245

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

example/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@
113113
<artifactId>netty-transport-rxtx</artifactId>
114114
<version>${project.version}</version>
115115
</dependency>
116+
<dependency>
117+
<groupId>ch.qos.logback</groupId>
118+
<artifactId>logback-classic</artifactId>
119+
<scope>runtime</scope>
120+
</dependency>
116121
</dependencies>
117122

118123
<build>
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<configuration debug="false">
2+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
3+
<encoder>
4+
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
5+
</encoder>
6+
</appender>
7+
8+
<root level="${logLevel:-info}">
9+
<appender-ref ref="STDOUT" />
10+
</root>
11+
</configuration>

run-example.sh

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ if [[ -z "$EXAMPLE" ]] || [[ -z "$EXAMPLE_CLASS" ]] || [[ $# -ne 0 ]]; then
7474
echo " Usage: $0 [-D<name>[=<value>] ...] <example-name>" >&2
7575
echo "Example: $0 -Dport=8443 -Dssl http-server" >&2
7676
echo " $0 -Dhost=127.0.0.1 -Dport=8009 echo-client" >&2
77+
echo " $0 -DlogLevel=debug -Dhost=127.0.0.1 -Dport=8009 echo-client" >&2
7778
echo >&2
7879
echo "Available examples:" >&2
7980
echo >&2

0 commit comments

Comments
 (0)