How to enable / disable / configure CLI command logging in JBoss EAP 6/7?

Solution Verified - Updated -

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6.x
    • 7.x

Issue

  • How to enable CLI command logging in JBoss EAP 6 to check detailed error message and understand why CLI command fails ?
  • Where does JBoss CLI commands logging stored ?
  • How can we increase log level of jboss-cli?
  • Is there a way to change the location of the log?

Resolution

  • To create CLI logging refer steps given below

Step 1 Goto $JBOSS_HOME/bin directory, and open jboss-cli-logging.properties file and change logging level from OFF to other logging level(Ex. TRACE)

. . .  
logger.org.level=TRACE
logger.org.jboss.as.cli.level=TRACE
 . . .

Step 2 Also in the jboss-cli-logging.properties specify Handler to log message in log file by uncommenting the line below:

 . . .
# uncomment to enable logging to the file
logger.handlers=FILE
. . .

Step 3 Check if "-Dlogging.configuration" has been setup in jboss-cli.sh (or jboss-cli.bat) , for example on Linux:

eval \"$JAVA\" $JAVA_OPTS \"-Dlogging.configuration=file:$JBOSS_HOME/bin/jboss-cli-logging.properties\" -jar \"$JBOSS_HOME/jboss-modules.jar\" -mp \"$JBOSS_HOME/modules\" org.jboss.as.cli '"$@"'

Or on Windows it looks like:

rem Add base package for L&F
set "JAVA_OPTS=%JAVA_OPTS% -Djboss.modules.system.pkgs=com.sun.java.swing -Dlogging.configuration=file:%JBOSS_HOME%\bin\jboss-cli-logging.properties"

Step 4 Reconnect to CLI terminal, and we will find jboss-cli.log under $JBOSS_HOME/bin directory.

Optional Steps

 * For the jboss-cli.log file to append rather than create a new jboss-cli.log file for each jboss-cli.sh (or jboss-cli.bat) invocation, add the following to under the `file handler configuration` in `jboss-cli-logging.properties` 
# File handler configuration
handler.FILE.properties=autoFlush,fileName,append
handler.FILE.constructorProperties=fileName,append
handler.FILE.append=true
* For the logs to rotate on a daily basis,  changes is required for the handler type, for example:

From

  handler.FILE=org.jboss.logmanager.handlers.FileHandler  

to

  handler.FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler

Add a property for suffix, e.g.

handler.FILE.suffix=.yyyy-MM-dd

Then add that property to the properties on the handler,

handler.FILE.properties=autoFlush,suffix,fileName

Note* It's order is important too,such that suffix comes before the fileName as it might need to rotate when it's first booted.

* For change of location of the "jboss-cli.log"

Change the line below in the JBOSS_HOME/bin/jboss-cli-logging.properties files

handler.FILE.fileName=${jboss.cli.log.file:../domain/log/jboss-cli.log}

So for the above it will take "present working directory" plus the directory part you specify, i.e. if JBOSS_HOME is /opt/jboss-eap and you're in /opt/jboss-eap then "../domain/jboss-cli.log" would be created in /opt/domain/jboss-cli.log

(or)

You could set a JAVA_OPTS in jboss-cli.sh or jboss-cli.bat

JAVA_OPTS="-Djboss.cli.log.file=$JBOSS_HOME/standalone/log/jboss-cli.log"

Note**
The jboss-cli.log file would be created once you start a new CLI connection to the server.

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.

Comments