Reputation: 136
I'm trying to get started with Apache storm by running the example code. I'm working with storm 0.10.1-beta1 off of a maven repository.
Unfortunately, when I run these, the console is flooded with info level logs, drowning out any System.out.print()
calls that I've added. Is it possible to change the log level when running off of a LocalCluster? I've tried the solutions listed here and none of the solutions seem to be working.
From the link, Changing the Config.TOPOLOGY_DEBUG
property to false doesn't remove the info level logs, and using the code from the link, I can't even use logger.setLevel((Level) Level.FATAL)
as I get "The method setLevel(Level) is undefined for the type Logger" despite it clearly being listed in the log4j api.
Edit 1:
I also tried the solution here and I put an xml called logback.xml
into ./src with the following config:
<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="WARN"/>
<Root level="WARN">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</configuration>
Still no luck though. Is there any additional config required to tell storm to use the custom log settings?
Update: It turns out that storm 0.10.x switched to using log4j2 instead of logback, so adding a log4j2.xml with the configuration above finally worked!
Upvotes: 7
Views: 2787
Reputation: 21
To define a system property -Dlog4j.configurationFile=log4j2.xml
is a keypoint on Storm 1.0.0
The log4j2.xml
could be a fake or non-existing file.
Upvotes: 1
Reputation: 20698
To make it clear for newbies:
When running on local cluster: Whether you use log4j
or slf4j
for your own application's logging, you will eventually have to use a log4j2.xml
or a logback.xml
file where you set the configuration of how you want logging to happen.
It is in this file; your own application's log4j or logback xml file, that you have to paste the configuration which tells your application not to show the logs.
So simply add this anywhere between the <configuration>
and </configuration>
tags.
<logger name="org.apache.storm" level="OFF"/>
<logger name="org.apache.zookeeper" level="OFF"/>
Upvotes: 1
Reputation: 62350
The following configuration works for me:
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="WARN">
<appender-ref ref="STDOUT" />
</root>
</configuration>
Upvotes: 1