Skip to content

Commit

Permalink
logging to files in tests (akka#611)
Browse files Browse the repository at this point in the history
All modules are now set up to log to files this makes the build output much easier for the human eye.

* Add akka-slf4j and logback as default dependency in Common
* Log to file consistently in all modules
* Append all log files to travis log
  • Loading branch information
ennru authored Nov 26, 2017
1 parent b1992d6 commit 6964334
Show file tree
Hide file tree
Showing 61 changed files with 483 additions and 182 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ script:
- git diff --exit-code --color || { echo "[error] Unformatted code found. Please run 'test:compile' and commit the reformatted code."; false; } && sbt -J-XX:ReservedCodeCacheSize=128m ++$TRAVIS_SCALA_VERSION ";testChanged"
# check policies, if on master also upload
- if [[ "$TRAVIS_SECURE_ENV_VARS" == "true" ]]; then if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_EVENT_TYPE" == "push" ]]; then sbt 'set credentials += Credentials("whitesource", "whitesourcesoftware.com", "", System.getenv("WHITESOURCE_KEY"))' whitesourceCheckPolicies whitesourceUpdate; else sbt 'set credentials += Credentials("whitesource", "whitesourcesoftware.com", "", System.getenv("WHITESOURCE_KEY"))' whitesourceCheckPolicies; fi ; fi
- find . -name "*.log" -exec ./scripts/cat-log.sh {} \;

after_failure:
- docker-compose logs mqtt
Expand Down
5 changes: 5 additions & 0 deletions amqp/src/test/resources/application.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
loglevel = "DEBUG"
}
13 changes: 13 additions & 0 deletions amqp/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>target/amqp.log</file>
<append>false</append>
<encoder>
<pattern>%d{ISO8601} %-5level [%thread] [%logger{36}] %msg%n</pattern>
</encoder>
</appender>

<root level="debug">
<appender-ref ref="FILE" />
</root>
</configuration>
5 changes: 5 additions & 0 deletions awslambda/src/test/resources/application.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
loglevel = "DEBUG"
}
13 changes: 13 additions & 0 deletions awslambda/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>target/awslambda.log</file>
<append>false</append>
<encoder>
<pattern>%d{ISO8601} %-5level [%thread] [%logger{36}] %msg%n</pattern>
</encoder>
</appender>

<root level="debug">
<appender-ref ref="FILE" />
</root>
</configuration>
5 changes: 5 additions & 0 deletions azure-storage-queue/src/test/resources/application.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
loglevel = "DEBUG"
}
13 changes: 13 additions & 0 deletions azure-storage-queue/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>target/azure-storage-queue.log</file>
<append>false</append>
<encoder>
<pattern>%d{ISO8601} %-5level [%thread] [%logger{36}] %msg%n</pattern>
</encoder>
</appender>

<root level="debug">
<appender-ref ref="FILE" />
</root>
</configuration>
6 changes: 1 addition & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,6 @@ def alpakkaProject(projectId: String, additionalSettings: sbt.Def.SettingsDefini
Project(id = projectId, base = file(projectId))
.enablePlugins(AutomateHeaderPlugin)
.settings(
name := s"akka-stream-alpakka-$projectId",
// By default scalatest futures time out in 150 ms, dilate that to 600ms.
// This should not impact the total test time as we don't expect to hit this
// timeout.
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-F", "4")
name := s"akka-stream-alpakka-$projectId"
)
.settings(additionalSettings: _*)
5 changes: 5 additions & 0 deletions cassandra/src/test/resources/application.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
loglevel = "DEBUG"
}
13 changes: 13 additions & 0 deletions cassandra/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>target/cassandra.log</file>
<append>false</append>
<encoder>
<pattern>%d{ISO8601} %-5level [%thread] [%logger{36}] %msg%n</pattern>
</encoder>
</appender>

<root level="debug">
<appender-ref ref="FILE" />
</root>
</configuration>
5 changes: 5 additions & 0 deletions csv/src/test/resources/application.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
loglevel = "DEBUG"
}
13 changes: 13 additions & 0 deletions csv/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>target/csv.log</file>
<append>false</append>
<encoder>
<pattern>%d{ISO8601} %-5level [%thread] [%logger{36}] %msg%n</pattern>
</encoder>
</appender>

<root level="debug">
<appender-ref ref="FILE" />
</root>
</configuration>
5 changes: 5 additions & 0 deletions dynamodb/src/test/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ akka.stream.alpakka.dynamodb {
region = "us-east-1"
parallelism = 5
}
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
loglevel = "DEBUG"
}
13 changes: 13 additions & 0 deletions dynamodb/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>target/dynamodb.log</file>
<append>false</append>
<encoder>
<pattern>%d{ISO8601} %-5level [%thread] [%logger{36}] %msg%n</pattern>
</encoder>
</appender>

<root level="debug">
<appender-ref ref="FILE" />
</root>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public static void setup() throws IOException {
runner.build(ElasticsearchClusterRunner.newConfigs()
.baseHttpPort(9200)
.baseTransportPort(9300)
.numOfNode(1));
.numOfNode(1)
.disableESLogger());
runner.ensureYellow();

//#init-client
Expand Down
5 changes: 5 additions & 0 deletions elasticsearch/src/test/resources/application.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
akka.stream.akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
loglevel = "DEBUG"
}
13 changes: 13 additions & 0 deletions elasticsearch/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>target/elasticsearch.log</file>
<append>false</append>
<encoder>
<pattern>%d{ISO8601} %-5level [%thread] [%logger{36}] %msg%n</pattern>
</encoder>
</appender>

<root level="debug">
<appender-ref ref="FILE" />
</root>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class ElasticsearchSpec extends WordSpec with Matchers with BeforeAndAfterAll {
.baseHttpPort(9200)
.baseTransportPort(9300)
.numOfNode(1)
.disableESLogger()
)
runner.ensureYellow()

Expand Down
5 changes: 5 additions & 0 deletions file/src/test/resources/application.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
loglevel = "DEBUG"
}
13 changes: 13 additions & 0 deletions file/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>target/files.log</file>
<append>false</append>
<encoder>
<pattern>%d{ISO8601} %-5level [%thread] [%logger{36}] %msg%n</pattern>
</encoder>
</appender>

<root level="debug">
<appender-ref ref="FILE" />
</root>
</configuration>
7 changes: 6 additions & 1 deletion ftp/src/test/resources/application.conf
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
akka.test.single-expect-default = 30 seconds
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
loglevel = "DEBUG"
}
akka.test.single-expect-default = 30 seconds
19 changes: 19 additions & 0 deletions ftp/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>target/ftp.log</file>
<append>false</append>
<encoder>
<pattern>%d{ISO8601} %-5level [%thread] [%logger{36}] %msg%n</pattern>
</encoder>
</appender>

<logger name="net.schmizz.sshj.DefaultConfig" level="error"/>
<logger name="net.schmizz" level="warn"/>
<logger name="org.apache.ftpserver" level="info"/>
<logger name="org.apache.mina" level="warn"/>
<logger name="org.apache.sshd" level="warn"/>

<root level="debug">
<appender-ref ref="FILE" />
</root>
</configuration>
44 changes: 0 additions & 44 deletions ftp/src/test/resources/logback.xml

This file was deleted.

5 changes: 5 additions & 0 deletions geode/src/test/resources/application.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
loglevel = "DEBUG"
}
6 changes: 3 additions & 3 deletions geode/src/test/resources/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<Property name="geode-default">true</Property>
</Properties>
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<File name="File" fileName="target/geode-log4j.log">
<PatternLayout pattern="${geode-pattern}"/>
</Console>
</File>
</Appenders>
<Loggers>
<Logger name="org.apache.geode" level="WARN" additivity="true">
Expand All @@ -17,7 +17,7 @@
</Logger>
<Logger name="org.jgroups" level="FATAL" additivity="true"/>
<Root level="WARN">
<AppenderRef ref="STDOUT"/>
<AppenderRef ref="File"/>
</Root>
</Loggers>
</Configuration>
14 changes: 14 additions & 0 deletions geode/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>target/geode.log</file>
<append>false</append>
<encoder>
<pattern>%d{ISO8601} %-5level [%thread] [%logger{36}] %msg%n</pattern>
</encoder>
</appender>

<root level="debug">
<appender-ref ref="FILE" />
</root>
</configuration>
16 changes: 0 additions & 16 deletions geode/src/test/resources/logback.xml

This file was deleted.

5 changes: 5 additions & 0 deletions google-cloud-pub-sub/src/test/resources/application.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
loglevel = "DEBUG"
}
13 changes: 13 additions & 0 deletions google-cloud-pub-sub/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>target/google-cloud-pub-sub.log</file>
<append>false</append>
<encoder>
<pattern>%d{ISO8601} %-5level [%thread] [%logger{36}] %msg%n</pattern>
</encoder>
</appender>

<root level="debug">
<appender-ref ref="FILE" />
</root>
</configuration>
20 changes: 20 additions & 0 deletions hbase/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>target/hbase.log</file>
<append>false</append>
<encoder>
<pattern>%d{ISO8601} %-5level [%thread] [%logger{36}] %msg%n</pattern>
</encoder>
</appender>

<logger name="akka.stream.alpakka.hbase" level="DEBUG"/>

<logger name="akka.stream" level="DEBUG"/>

<logger name="org.apache.hadoop.security" level="INFO"/>

<root level="debug">
<appender-ref ref="FILE" />
</root>
</configuration>
Loading

0 comments on commit 6964334

Please sign in to comment.