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 of log:
261 [main] INFO backtype.storm.daemon.task - Shut down task Getting-Started-Toplogie-1-1376388324:2
2261 [main] INFO backtype.storm.daemon.task - Shutting down task Getting-Started-Toplogie-1-1376388324:1
2262 [Thread-24] INFO backtype.storm.util - Async loop interrupted!
2276 [main] INFO backtype.storm.daemon.task - Shut down task Getting-Started-Toplogie-1-1376388324:1
2278 [main] INFO backtype.storm.daemon.worker - Terminating zmq context
2279 [main] INFO backtype.storm.daemon.worker - Disconnecting from storm cluster state context
2279 [main] INFO backtype.storm.daemon.worker - Waiting for heartbeat thread to die
2279 [Thread-27] INFO backtype.storm.util - Async loop interrupted!
2308 [main] INFO backtype.storm.testing - Shutting down in process zookeeper
2309 [main] INFO backtype.storm.testing - Done shutting down in process zookeeper
2309 [main] INFO backtype.storm.testing - Deleting temporary path /tmp/255fe7c8-1407-4f43-8771-2217905232ab
After going through many docs, I ended up with the below code, I am able to turn off the logging from within class.
static Logger logger = Logger.getLogger(TopologyMain.class);
public static void main(String[] args) throws InterruptedException, AlreadyAliveException, InvalidTopologyException {
logger.setLevel((Level) Level.FATAL);
logger.debug("Here is some DEBUG");
logger.info("Here is some INFO");
logger.warn("Here is some WARN");
logger.error("Here is some ERROR");
logger.fatal("Here is some FATAL");
}
}
Output (correct) : 0 [main] FATAL TopologyMain - Here is some FATAL
But I require to change the logging configure of storm/zookeper,etc..
Could anyone please help on this?
Update: The following is the code I tried, but it does not work. I tried with version 0.7.1, 0.8.2 & 0.9.0-wip*
//Configuration
Config conf = new Config();
conf.put(Config.TOPOLOGY_DEBUG, false); //Tried this alone
conf.setDebug(false); //Tried this alone & tried both together as well.. No change :-(
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.
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.
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());
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!
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
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>