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 :-(
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):
For more details please check this link
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.
This works for me (storm version 0.9.0.1):
I found this question when attempting to evaluate Storm using a local testing environment. I created a project depending on
storm-core
version1.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 calledlog4j2.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 newlog4j2.xml
file undersrc/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":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 ofSystem.out.println()
I placed in my test spouts / bolts. This is exactly what I wanted! Hopefully this helps someone other than me!Creat a file "log4j2.xml" in src/main/resources (Maven project) works for me!
Add below code in log4j.xml.It will just print your intended logs and console outputs :-
And use Logger.getLogger(Class) in your classes.