Change logging levels using CLI commands in JBoss EAP

Solution Verified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6.x
    • 7.x
    • 8.x
  • JBoss EAP Command Line Interface (CLI)
  • Red Hat Single Sign-On (RH-SSO) 7.x
  • Logging

Issue

  • Change the logging levels using the CLI.
  • Enable logging on a specific package.
  • The logging subsystem and logging.properties are set to INFO as a minimum, yet TRACE, DEBUG, FINE, and FINER messages appear for module package names.
  • How to start the server in debug mode?
  • How to change logging levels without a restart?
  • In JBoss EAP 4, jboss-services.xml could be used to log when configuration changes take effect. Is there something similar in newer versions?

Resolution

Connect to the management CLI using either $EAP_HOME/bin/jboss-cli.sh -c or %EAP_HOME%\bin\jboss-cli.bat -c and run the appropriate command below. Logging level changes made through the CLI take effect immediately, without a server restart.

  • To change the logging level for all categories, modify the root logger, replacing NEW_LOGGING_LEVEL with the desired level:

    /subsystem=logging/root-logger=ROOT:write-attribute(name=level,value=NEW_LOGGING_LEVEL)
    
  • To enable logging for a specific package that does not yet have a logger defined:

    /subsystem=logging/logger=package.name:add(category=package.name,level=INFO,use-parent-handlers=true)
    

    The command adds a logger for the specified package at the INFO level. Other levels such as DEBUG or TRACE can be specified, and java.util.logging level names such as FINE, FINER, and FINEST are also accepted. The package name can be, for example, org.jboss.security or io.undertow.

  • To change the logging level of an existing logger:

    /subsystem=logging/logger=package.name:write-attribute(name=level,value=NEW_LOGGING_LEVEL)
    

    Note: The change-log-level operation performs the same change but is deprecated (deprecated since logging subsystem model 1.2.0; JBoss EAP 8 returns warning WFLYCTL0449 when it is invoked). Use write-attribute instead.

Note: The commands above apply to standalone mode. In domain mode, prefix each command with /profile=Profile_Name/, where Profile_Name is the profile being used. For example:

/profile=Profile_Name/subsystem=logging/root-logger=ROOT:write-attribute(name=level,value=NEW_LOGGING_LEVEL)
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.