How to dynamically change the StreamBase log level during runtime

How to dynamically change the StreamBase log level during runtime

book

Article ID: KB0075987

calendar_today

Updated On:

Products Versions
TIBCO Streaming 7

Description

How to dynamically change the StreamBase log level during runtime

Issue/Introduction

How to dynamically change the StreamBase log level during runtime

Resolution

Note: TIBCO Streaming 10.x and later supports JMS and logback as described below, and additional facilities. The epadmin command replaces sbadmin. Please see the current product documentation.

The following guidance assumes you are using the default Logback logging back end for your StreamBase applications. The StreamBase-supported Log4j version (1.2) does not automatically enable JMX monitoring by default, as the org.apache.log4j.jmx package is not of production quality (go here for more details).  Hence, instructions for dynamically changing the log level when using Log4j are not included in this article.

To dynamically change the log level of a running StreamBase server instance, you must modify your default Logback configuration. Modifying the Logback configuration can be done in one of two ways:

1. Enable JMX monitoring and perform a setLoggerLevel() operation.

You may enable JMX monitoring in StreamBase by setting the following Java system properties:
  • com.sun.management.jmxremote (enables local monitoring)
  • com.sun.management.jmxremote.port=12000 (enables remote monitoring)

Be aware that JMX authentication is enabled by default for remote monitoring, as stated in Oracle's documentation). To disable security for testing purposes, set the following additional properties:
  • com.sun.management.jmxremote.authenticate=false
  • com.sun.management.jmxremote.ssl=false"

These properties can be set in your StreamBase configuration file ( *.sbconf) under the <java-vm> element. For example:
 
<java-vm>
<param name="jvm-args" value="-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=12000
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false" />
<!-- WARNING: the above configuration is not secure,
and should *not be used in production* -->
</java-vm>


After enabling JMX monitoring, you can perform a setLoggerLevel() operation using any JMX client. The image below shows an example using the JConsole client. Navigate to the MBeans tab, drill down under ch.qos.logback.classic > default > ch.qos.logback.classic.jmx.JMXConfigurator > Operations > setLoggerLevel(p1,p2), and specify the logger name and log level you want to set.

For more details on JMX monitoring with Logback, refer to the Logback JMX Configurator page.

2. Directly edit the Logback configuration file (e.g. logback.xml), and rescan it to apply the changes.

Rescanning can occur automatically by including the scan and scanPeriod attributes in the <configuration> element in logback.xml. For example:
 

<configuration scan="true" scanPeriod="30 seconds">
<jmxConfigurator />

<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%date [%thread] %-5level %logger{25} - %msg%n</Pattern>
</layout>
</appender>

<root level="info">
<appender-ref ref="console" />
</root>
</configuration>


The above example will automatically re-scan the configuration every 30 seconds. For more details on configuring automatic re-scanning, refer to the Logback Configuration page under the sub-heading  Automatically reloading configuration file upon modification

If you do not want to configure Logback for automatic rescanning, you can rescan the configuration file manually by performing a reloadDefaultConfiguration() operation through JConsole. In JConsole, go to the MBeans tab, and drill down under ch.qos.logback.classic > default > ch.qos.logback.classic.jmx.JMXConfigurator > Operations > reloadDefaultConfiguration.



---

In some cases, it may be preferable to only change the log level of individual operators/adapters, rather than change the log level for all server events. In this case, you may use the sbadmin setOperatorProperty command. For example:

sbadmin setOperatorProperty MyOperatorName logLevel DEBUG

For details on using sbadmin setOperatorProperty, refer to the Help under StreamBase Documentation > StreamBase References > StreamBase Command Reference > sbadmin

---