How to disable/turn off the logging feature from Storm

后端 未结 6 1918
傲寒
傲寒 2021-02-04 07:07

I want to turn off the logging feature offered by default when we run from local cluster. Currently its logging so many information on the console.

Below is the example

相关标签:
6条回答
  • 2021-02-04 07:41

    There is a nice documentation on setting up the log level dynamically. It can be done through the UI as well as using the CLI. The later looks better to me. Once you start the topology you can simply use the following command (from inside Storm's installation directory):

        ./bin/storm set_log_level [topology name] -l [logger name]=[LEVEL]:[TIMEOUT]
    

    For more details please check this link

    0 讨论(0)
  • 2021-02-04 07:42

    Add below code in log4j.xml.It will just print your intended logs and console outputs :-

    <logger name="org.apache.zookeeper">
            <level value="warn"/>
        </logger>
    
        <logger name="backtype.storm">
            <level value="warn"/>
        </logger>
    
        <logger name="com.netflix">
            <level value="warn"/>
        </logger>
    

    And use Logger.getLogger(Class) in your classes.

    0 讨论(0)
  • 2021-02-04 07:48

    This works for me (storm version 0.9.0.1):

    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout(..);
    builder.setBolt(..);
    :
    
    Config conf = new Config();
    conf.put(Config.TOPOLOGY_DEBUG, false);
    
    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology("topologyName", conf, builder.createTopology());
    
    0 讨论(0)
  • 2021-02-04 07:57

    Storm is really chatty and tells a lot of information but if you want to silence it, you can set Config.TOPOLOGY_DEBUG to false.

    When you set Config.TOPOLOGY_DEBUG to true, you are telling Storm to log a message every time a tuple is emitted from any spout or bolt.

    0 讨论(0)
  • 2021-02-04 08:02

    I found this question when attempting to evaluate Storm using a local testing environment. I created a project depending on storm-core version 1.1.0, which is the latest stable release at the time of this writing, so I don't know if this applies for anyone else.

    Inspecting the Maven dependencies, and expanding the contents of the storm-core-1.1.0.jar revealed that the configuration file for the library's log4j logging dependency was called log4j2.xml. With the realization that the logging mechanism was log4j 2 , I consulted the documentation here: https://logging.apache.org/log4j/2.x/manual/index.html I created a new log4j2.xml file under src/main/resources (my project is Maven-configured, so this is at the classpath root). I started by copying the contents of the existing file, and changing the log levels for the specified loggers to "OFF":

    <?xml version="1.0" encoding="UTF-8"?>
        <configuration monitorInterval="60">
          <Appenders>
            <Console name="Console" target="SYSTEM_OUT">
              <PatternLayout pattern="%-4r [%t] %-5p %c{1.} - %msg%n"/>
            </Console>
          </Appenders>
        <Loggers>
           <Logger name="org.apache.zookeeper" level="OFF"/>
             <Root level="OFF">
               <AppenderRef ref="Console"/>
             </Root>
        </Loggers>
    </configuration>
    

    Running a "hello world" example, regardless of the setting of conf.debug() indicates that - since there is now no mechanism by which logging should be possible at all - the logs (most usefully System.out) are now dead silent, except for the invocations of System.out.println() I placed in my test spouts / bolts. This is exactly what I wanted! Hopefully this helps someone other than me!

    0 讨论(0)
  • 2021-02-04 08:03

    Creat a file "log4j2.xml" in src/main/resources (Maven project) works for me!

    <Loggers>
        <Logger name="org.apache.storm" level="OFF"/>
        <Logger name="org.apache.zookeeper" level="OFF"/>
        <Root level="OFF">
            <AppenderRef ref="Console"/>
        </Root>
    </Loggers>
    

    0 讨论(0)
提交回复
热议问题