Skip to content

Commit

Permalink
Add script for automatically adding console loggers (#425)
Browse files Browse the repository at this point in the history
This script automatically adds the console loggers when they have not yet been configured (see [server mode](https://github.com/openhab/openhab-docker#server-mode)).

Signed-off-by: Wouter Born <[email protected]>
  • Loading branch information
wborn committed Jul 29, 2023
1 parent a580c3d commit 741f103
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions contrib/cont-init.d/20-add-console-loggers
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

CONFIG_FILE="${OPENHAB_USERDATA}/etc/log4j2.xml"
OSGI_AREF='<AppenderRef ref="OSGI"/>'
STDOUT_AREF='<AppenderRef ref="STDOUT"/>'

if [ "$(grep "${STDOUT_AREF}" "${CONFIG_FILE}" | wc -l)" == "1" ]; then
echo "Adding console loggers to ${CONFIG_FILE}"
sed -i "s#${OSGI_AREF}#${OSGI_AREF}\n\t\t\t${STDOUT_AREF}#g" "${CONFIG_FILE}"
fi

0 comments on commit 741f103

Please sign in to comment.