Search code examples
apache-storm

Set Log Level of Storm Topology from Start


I have a bug that occurs in my Storm topology during initialization. I would like to set the log level to DEBUG from when the topology is started.

I realize there is a mechanism to dynamically set the log level for a running topology using either the Storm UI or CLI, but I am not able to dynamically change this setting before the bug occurs in my topology during initialization.

How can I statically set the log level to DEBUG so that I can see more detailed logs when my topology is initialized?


Solution

  • The following only applies to Storm 2.0.0 and later.

    You can include a log4j2 config file in your topology jar. You then need to set the topology.logging.config property in your topology configuration.

    I'll include the documentation here for convenience:

    Log file the user can use to configure Log4j2. Can be a resource in the jar (specified with classpath:/path/to/resource) or a file. This configuration is applied in addition to the regular worker log4j2 configuration. The configs are merged according to the rules here: https://logging.apache.org/log4j/2.x/manual/configuration.html#CompositeConfiguration

    See https://github.com/apache/storm/blob/885ca981fc52bda6552be854c7e4af9c7a451cd2/storm-client/src/jvm/org/apache/storm/Config.java#L735

    The "regular worker log4j2 configuration" is the log4j2/worker.xml file in your Storm deployment, assuming default settings.