-
-
Save jmesnil/78581f90c68f84ba9240ef48f627ff45 to your computer and use it in GitHub Desktop.
change-log-level is a script to change the logging level of the WildFly server inside an application image running on any Kubernetes cluster.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
############################################################################################ | |
# # | |
# change-log-level is a script to change the logging level of the WildFly server # | |
# inside an application image running on any Kubernetes cluster. # | |
# # | |
# This script can be used with application images created either from WildFly S2I images # | |
# or Bootable Jar # | |
# # | |
############################################################################################ | |
help() { | |
script_name=${0##*/} | |
echo " | |
$script_name is a script to change the logging level of the WildFly server inside an application image running on any Kubernetes cluster. | |
Usage: | |
$script_name <pod> <logging-level> | |
Where the parameters are: | |
* <pod> - Name of the pod running the application image | |
* <logging-level> - The logging level to set (can be one of ALL, FINEST, FINER, TRACE, DEBUG, FINE, CONFIG, INFO | |
WARN, WARNING, ERROR, SEVERE, FATAL, OFF) | |
" | |
exit 1 | |
} | |
POD=$1 | |
LEVEL=$2 | |
if [ "x$POD" == "x" ]; then | |
help | |
fi | |
if [ "x$LEVEL" == "x" ]; then | |
help | |
fi | |
echo "Change logging level to ${LEVEL} for WildFly server in ${POD}" | |
WILDFLY_COMMANDS="/subsystem=logging/console-handler=CONSOLE:write-attribute\(name=level,value=$LEVEL\),/subsystem=logging/root-logger=ROOT:write-attribute\(name=level,value=$LEVEL\)" | |
kubectl exec ${POD} -- sh -c "[ -e /opt/jboss/container/wildfly-bootable-jar/install-dir ] && JBOSS_HOME=\$( cat /opt/jboss/container/wildfly-bootable-jar/install-dir ); \$JBOSS_HOME/bin/jboss-cli.sh -c --echo-command --commands=${WILDFLY_COMMANDS}" | |
WILDFLY_COMMANDS="/subsystem=logging/console-handler=CONSOLE:write-attribute\(name=level,value=DEBUG\),/subsystem=logging/root-logger=ROOT:write-attribute\(name=level,value=$LEVEL\)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment