Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 645
holmes840 Avatar asked Sep 05 '14 06:09

holmes840


People also ask

Where is the log4j log file?

The Log4j logging settings are stored in the file app_data /conf/server/log4j. properties, where app_data is the application data folder. You can edit this file directly on the server or open it by clicking Settings > Logging.

What is LOG4J2 used for?

LOG4J2 and LOG4J2 are de facto standard frameworks for logging application messages in Java. Basically, when you are developing Java applications, you include several statements that log information according to the level that you are setting.

What is log4j and how it works?

Log4j is an open source project based on the work of many authors. It allows the developer to control which log statements are output with arbitrary granularity. It is fully configurable at runtime using external configuration files. Best of all, log4j has a gentle learning curve.

What is a log Appender?

The appender is the part of a logging system that's responsible for sending the log messages to some destination or medium. It answers the question "where do you want to store this stuff?"


1 Answers

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

like image 152
Naresh Avatar answered Sep 28 '22 12:09

Naresh