Skip to content

Instantly share code, notes, and snippets.

@jmesnil
Created June 11, 2021 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmesnil/78581f90c68f84ba9240ef48f627ff45 to your computer and use it in GitHub Desktop.
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.
#!/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