How to write logs to a file using Log4j and Storm Framework?

holmes840 picture holmes840 · Sep 5, 2014 · Viewed 11.6k times · Source

I am having bit of an issue in logging to a file using log4j in storm .

Before submitting my topology , i.e in my main method I wrote some log statements and configured the logger using :

PropertyConfigurator.configure(myLog4jProperties)
  • Now when I run my topology using my executable jar in eclipse - its working fine and log files are being created as supposed.
    OR
    When i run my executable jar using "java -jar MyJarFile someOtherOptions", i can see log4j being configured and the files are formed correctly and logging is done on both files and console (as defined in my log4j.properties)

  • BUT when i run the same jar using "storm jar MyJarFile MyMainClass someOtherOptions" it is not being able to create and log into any of the files except on console.

I am talking about the logs I am printing BEFORE submitting my topology.

Is there any way to log my statements in a file while using storm ? I am not bound to use org.apache.log4j.

Answer

Naresh picture Naresh · Sep 5, 2014

The storm framework uses its own logging. Your logs most likely will end up in the logs dir where storm is installed({Storm DIR}/logs). You can find the storm log properties in {Storm DIR}/logback/cluster.xml. It uses logback not log4j