0
votes

I have a logging.properties where handlers are java.util.logging.FileHandler,java.util.logging.ConsoleHandler.

default logging level for root logger is set to INFO.

The logging file is passed to JVM_OPTS at startup.

How can I override the level to say "FINEST" or "DEBUG" at runtime without restart of server using java.util.logging?

1
Are you using Undertow as a standalone server or as part of WildFly or JBoss EAP?James R. Perkins
I happen to come back here as I need to implement now :) I am using undertow as standalone server though wildfly jars are shipped with the latest undertow versions now. fyi, this is used in the container world.Sayantan Ganguly

1 Answers

1
votes

You want to use ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class) to access the operations. The easy way to do that is to use a tool that supports MBean access.

Connecting JConsole to Undertow (locally or remotely) and use the MBean tab to change the logger level is the ideal way. One issue is that the logger names don't exist unless the code has triggered the creation of a logger. You can't use the MBean to create a logger ahead of the code running. If you are using JConsole locally make sure it is running under the same account as Undertow.

  1. Start JConsole using the same O/S account Undertow is running under.
  2. Connect Jconsole to Undertow
  3. Select the MBeans tab.
  4. Expand the tree nodes for java.util.logging->Logging->Operations
  5. Select setLoggerLevel.
  6. Enter the exact logger name in p0. If it is the root logger then input is blank.
  7. Enter the level name in p1. In this case it would be FINEST.
  8. Click setLoggerLevel. If the operation works you will see Method successfully invoked.

Similar steps can be performed with JMXTerm.