Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Commit

Permalink
Merge pull request #501 from dennisgranath/use_slf4j_and_logback
Browse files Browse the repository at this point in the history
Improve logging by introducing slf4j and logback
  • Loading branch information
diemol authored Mar 28, 2018
2 parents 0ace27d + b5e2a0c commit d9d08f2
Show file tree
Hide file tree
Showing 26 changed files with 319 additions and 277 deletions.
12 changes: 1 addition & 11 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -330,16 +330,6 @@ RUN cd /tmp \
USER seluser
WORKDIR /home/seluser

#==========
# Selenium
#==========
# Layer size: medium: 21.23 MB
ENV SEL_MAJOR_VER="${selenium-server.major-minor.version}" \
SEL_PATCH_LEVEL_VER="${selenium-server.patch-level.version}"
ENV SEL_VER="${SEL_MAJOR_VER}.${SEL_PATCH_LEVEL_VER}"
RUN export SELBASE="https://selenium-release.storage.googleapis.com" \
&& export SELPATH="${SEL_MAJOR_VER}/selenium-server-standalone-${SEL_VER}.jar" \
&& wget -nv ${SELBASE}/${SELPATH}

#==========
# Zalenium
Expand Down Expand Up @@ -383,7 +373,7 @@ COPY zalenium.sh \
index.html \
zalando.ico \
logging_info.properties \
logging_fine.properties \
logging_debug.properties \
logback.xml \
/home/seluser/
COPY scm-source.json /
Expand Down
5 changes: 5 additions & 0 deletions docs/_posts/2000-01-05-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,11 @@ you can explicitly tell Zalenium which version you are using via `-e DOCKER=17.0
<td>false</td>
<td>Enables LogLevel.FINE.</td>
</tr>
<tr>
<td><code>--logJson</code></td>
<td>false</td>
<td>Output logs in json format</td>
</tr>
<tr>
<td><code>--seleniumImageName</code></td>
<td>"elgalu/selenium"</td>
Expand Down
58 changes: 30 additions & 28 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
<awaitility.version>3.1.0</awaitility.version>
<testng.version>6.14.2</testng.version>
<slf4j.version>1.7.25</slf4j.version>
<logstash-logback-encoder.version>5.0</logstash-logback-encoder.version>
<maven.compiler.source>1.8</maven.compiler.source>
<ch.qos.logback.version>1.2.3</ch.qos.logback.version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.plugin>3.7.0</maven.compiler.plugin>
<maven-resources-plugin.version>3.0.2</maven-resources-plugin.version>
Expand Down Expand Up @@ -112,11 +114,36 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${ch.qos.logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${ch.qos.logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-access</artifactId>
<version>${ch.qos.logback.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<artifactId>jul-to-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>${logstash-logback-encoder.version}</version>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>openshift-server-mock</artifactId>
Expand Down Expand Up @@ -198,7 +225,7 @@
<directory>src/main/resources</directory>
<includes>
<include>logging_info.properties</include>
<include>logging_fine.properties</include>
<include>logging_debug.properties</include>
<include>logback.xml</include>
</includes>
</resource>
Expand Down Expand Up @@ -260,32 +287,7 @@
</filter>
</filters>
<artifactSet>
<excludes>
<exclude>org.seleniumhq.selenium:*</exclude>
<exclude>com.beust:*</exclude>
<exclude>net.bytebuddy:*</exclude>
<!--exclude>org.apache.commons:*</exclude-->
<exclude>org.w3c.css:*</exclude>
<exclude>net.sourceforge.cssparser:*</exclude>
<exclude>net.sourceforge.htmlunit:*</exclude>
<exclude>org.eclipse.jetty:*</exclude>
<exclude>org.eclipse.jetty.websocket:*</exclude>
<exclude>commons-codec:*</exclude>
<exclude>commons-io:*</exclude>
<exclude>commons-logging:*</exclude>
<exclude>commons-net:*</exclude>
<exclude>com.google.guava:*</exclude>
<exclude>com.google.code.findbugs:*</exclude>
<exclude>com.google.errorprone:*</exclude>
<exclude>com.google.j2objc:*</exclude>
<exclude>org.codehaus.mojo:*</exclude>
<exclude>org.apache.httpcomponents:*</exclude>
<exclude>net.jcip:*</exclude>
<exclude>xalan:*</exclude>
<exclude>xerces:*</exclude>
<exclude>xml-apis:*</exclude>
<exclude>org.yaml:*</exclude>
</excludes>

</artifactSet>
</configuration>
</execution>
Expand Down
48 changes: 28 additions & 20 deletions scripts/zalenium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ CHROME_CONTAINERS=1
FIREFOX_CONTAINERS=1
DESIRED_CONTAINERS=2
MAX_DOCKER_SELENIUM_CONTAINERS=10
SELENIUM_ARTIFACT="$(pwd)/selenium-server-standalone-${selenium-server.major-minor.version}.${selenium-server.patch-level.version}.jar"
ZALENIUM_ARTIFACT="$(pwd)/${project.build.finalName}.jar"
DEPRECATED_PARAMETERS=false
SAUCE_LABS_ENABLED=false
Expand All @@ -21,6 +20,7 @@ SEND_ANONYMOUS_USAGE_INFO=true
START_TUNNEL=false
DEBUG_ENABLED=false
KEEP_ONLY_FAILED_TESTS=false
LOG_JSON=false
NEW_SESSION_WAIT_TIMEOUT=${NEW_SESSION_WAIT_TIMEOUT:-300000}

GA_TRACKING_ID="UA-88441352-3"
Expand Down Expand Up @@ -284,13 +284,6 @@ StartUp()
fi
fi

log "Running additional checks..."
if [ ! -f ${SELENIUM_ARTIFACT} ];
then
echo "Selenium JAR not present, exiting start script."
exit 2
fi

if [ ! -f ${ZALENIUM_ARTIFACT} ];
then
echo "Zalenium JAR not present, exiting start script."
Expand Down Expand Up @@ -423,13 +416,20 @@ StartUp()

DEBUG_MODE=info
if [ "$DEBUG_ENABLED" = true ]; then
DEBUG_MODE=fine
DEBUG_MODE=debug
DEBUG_FLAG=-debug
fi

java ${ZALENIUM_EXTRA_JVM_PARAMS} -Djava.util.logging.config.file=logging_${DEBUG_MODE}.properties \
-Dlogback.configurationFile=logback.xml \
-cp ${SELENIUM_ARTIFACT}:${ZALENIUM_ARTIFACT} org.openqa.grid.selenium.GridLauncherV3 \
LOGBACK_APPENDER=STDOUT

if [ "$LOG_JSON" == true ]; then
LOGBACK_APPENDER=JSON
fi

java ${ZALENIUM_EXTRA_JVM_PARAMS} -Dlogback.loglevel=${DEBUG_MODE} \
-Dlogback.appender=${LOGBACK_APPENDER} \
-Djava.util.logging.config.file=logging_${DEBUG_MODE}.properties \
-cp ${ZALENIUM_ARTIFACT} org.openqa.grid.selenium.GridLauncherV3 \
-role hub -port 4445 -newSessionWaitTimeout ${NEW_SESSION_WAIT_TIMEOUT} \
-servlet de.zalando.ep.zalenium.servlet.LivePreviewServlet \
-servlet de.zalando.ep.zalenium.servlet.ZaleniumConsoleServlet \
Expand All @@ -452,8 +452,9 @@ StartUp()

echo "Starting DockerSeleniumStarter node..."

java -Djava.util.logging.config.file=logging_${DEBUG_MODE}.properties \
-jar ${SELENIUM_ARTIFACT} -role node -hub http://localhost:4444/grid/register \
java -Dlogback.loglevel=${DEBUG_MODE} -Dlogback.appender=${LOGBACK_APPENDER} \
-Djava.util.logging.config.file=logging_${DEBUG_MODE}.properties \
-cp ${ZALENIUM_ARTIFACT} org.openqa.grid.selenium.GridLauncherV3 -role node -hub http://localhost:4444/grid/register \
-registerCycle 0 -proxy de.zalando.ep.zalenium.proxy.DockerSeleniumStarterRemoteProxy \
-nodePolling 90000 -port 30000 ${DEBUG_FLAG} &
echo $! > ${PID_PATH_DOCKER_SELENIUM_NODE}
Expand All @@ -477,8 +478,9 @@ StartUp()

if [ "$SAUCE_LABS_ENABLED" = true ]; then
echo "Starting Sauce Labs node..."
java -Djava.util.logging.config.file=logging_${DEBUG_MODE}.properties \
-jar ${SELENIUM_ARTIFACT} -role node -hub http://localhost:4444/grid/register \
java -Dlogback.loglevel=${DEBUG_MODE} -Dlogback.appender=${LOGBACK_APPENDER} \
-Djava.util.logging.config.file=logging_${DEBUG_MODE}.properties \
-cp ${ZALENIUM_ARTIFACT} org.openqa.grid.selenium.GridLauncherV3 -role node -hub http://localhost:4444/grid/register \
-registerCycle 0 -proxy de.zalando.ep.zalenium.proxy.SauceLabsRemoteProxy \
-nodePolling 90000 -port 30001 ${DEBUG_FLAG} &
echo $! > ${PID_PATH_SAUCE_LABS_NODE}
Expand All @@ -504,8 +506,9 @@ StartUp()

if [ "$BROWSER_STACK_ENABLED" = true ]; then
echo "Starting Browser Stack node..."
java -Djava.util.logging.config.file=logging_${DEBUG_MODE}.properties \
-jar ${SELENIUM_ARTIFACT} -role node -hub http://localhost:4444/grid/register \
java -Dlogback.loglevel=${DEBUG_MODE} -Dlogback.appender=${LOGBACK_APPENDER} \
-Djava.util.logging.config.file=logging_${DEBUG_MODE}.properties \
-cp ${ZALENIUM_ARTIFACT} org.openqa.grid.selenium.GridLauncherV3 -role node -hub http://localhost:4444/grid/register \
-registerCycle 0 -proxy de.zalando.ep.zalenium.proxy.BrowserStackRemoteProxy \
-nodePolling 90000 -port 30002 ${DEBUG_FLAG} &
echo $! > ${PID_PATH_BROWSER_STACK_NODE}
Expand All @@ -530,8 +533,9 @@ StartUp()

if [ "$TESTINGBOT_ENABLED" = true ]; then
echo "Starting TestingBot node..."
java -Djava.util.logging.config.file=logging_${DEBUG_MODE}.properties \
-jar ${SELENIUM_ARTIFACT} -role node -hub http://localhost:4444/grid/register \
java -Dlogback.loglevel=${DEBUG_MODE} -Dlogback.appender=${LOGBACK_APPENDER} \
-Djava.util.logging.config.file=logging_${DEBUG_MODE}.properties \
-cp ${ZALENIUM_ARTIFACT} org.openqa.grid.selenium.GridLauncherV3 -role node -hub http://localhost:4444/grid/register \
-registerCycle 0 -proxy de.zalando.ep.zalenium.proxy.TestingBotRemoteProxy \
-nodePolling 90000 -port 30003 ${DEBUG_FLAG} &
echo $! > ${PID_PATH_TESTINGBOT_NODE}
Expand Down Expand Up @@ -769,6 +773,7 @@ function usage()
echo -e "\t --timeZone -> Sets the time zone in the containers. Defaults to \"Europe/Berlin\""
echo -e "\t --sendAnonymousUsageInfo -> Collects anonymous usage of the tool. Defaults to 'true'"
echo -e "\t --debugEnabled -> enables LogLevel.FINE. Defaults to 'false'"
echo -e "\t --logJson -> output logs in json format. Defaults to 'false'"
echo -e "\t --seleniumImageName -> enables overriding of the Docker selenium image to use. Defaults to \"elgalu/selenium\""
echo -e "\t --gridUser -> allows you to specify a user to enable basic auth protection, --gridPassword must be provided also."
echo -e "\t --gridPassword -> allows you to specify a password to enable basic auth protection, --gridUser must be provided also."
Expand Down Expand Up @@ -848,6 +853,9 @@ case ${SCRIPT_ACTION} in
--debugEnabled)
DEBUG_ENABLED=${VALUE}
;;
--logJson)
LOG_JSON=${VALUE}
;;
--seleniumImageName)
SELENIUM_IMAGE_NAME=${VALUE}
;;
Expand Down
Loading

0 comments on commit d9d08f2

Please sign in to comment.