Created 07-15-2016 01:05 AM
I am working on adding a Squid telemetry to an Ambari-managed cluster on AWS. I've parsed and transformed the Squid message, but I am getting the following error message when I attempt to push it to Zookeeper:
[root@ip-10-0-0-90 ~]# /usr/metron/0.2.0BETA/bin/zk_load_configs.sh -i /usr/metron/0.2.0BETA/config/zookeeper -m PUSH -z ec2-xx-xx-xxx-xxx.us-west-2.compute.amazonaws.com:2181
log4j:WARN No appenders could be found for logger (org.apache.curator.framework.imps.CuratorFrameworkImpl).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
I checked the referenced Apache FAQ and found the following answer:
Created 07-15-2016 08:28 PM
The above answer gives a lot of good detail, but for what you're trying to do, the WARN messages are actually okay. Though, I'll be happy when they're gone.
If you run /usr/metron/0.2.0BETA/bin/zk_load_configs.sh -i /usr/metron/0.2.0BETA/config/zookeeper -m DUMP -z hostname:2181 you should see the changes you PUSHed.
Created 07-15-2016 01:27 AM
Logging output is written to a target by using an appender. If no appenders are attached to a category nor to any of its ancestors, you will get the following message when trying to log:
log4j:No appenders could be found for category (some.category.name). log4j:Please initialize the log4j system properly.
Log4j does not have a default logging target. It is the user's responsibility to ensure that all categories can inherit an appender. This can be easily achieved by attaching an appender to the root category.
You can find info on how to configure the root logger (log4j.rootLogger
) in the log4j documentation, basically adding something as simple as this at the beginning of the file:
log4j.rootLogger=debug, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=...
This should clear those WARN messages you get on startup (make sure you don't already have an appender named stdout
; also be careful of what level you give the root logger, debug
will be very verbose and every library in your app will start writing stuff to the console).
In a nutshell, you're missing the log4j.properties
or log4j.xml
in your classpath.
You can also bypass this by using
BasicConfigurator.configure();
But beware this will ONLY log to System.out and is not recommended. You should really use one of the files above and write to a log file.
A very simple example of log4j.properties
would also be
#Log to Console as STDOUT log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss}%-5p%c %3x-%m%n #Log to file FILE log4j.appender.file=org.apache.log4j.DailyRollingFileAppender log4j.appender.file.File=logfile.log log4j.appender.file.DatePattern='.'yyyy-MM-dd log4j.appender.file.append=true log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss}%-5p%c %3x-%m%n #RootLogger log4j.rootLogger=INFO, stdout, file
Created 07-15-2016 08:28 PM
The above answer gives a lot of good detail, but for what you're trying to do, the WARN messages are actually okay. Though, I'll be happy when they're gone.
If you run /usr/metron/0.2.0BETA/bin/zk_load_configs.sh -i /usr/metron/0.2.0BETA/config/zookeeper -m DUMP -z hostname:2181 you should see the changes you PUSHed.