You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by Isaac Levy <Is...@coxautoinc.com> on 2016/10/12 18:29:56 UTC

stand alone avro-tools prints log4j warning

Is there any way to silence these?

$ java -jar avro-tools-1.8.1.jar tojson foo
log4j:WARN No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

Looks like avro-tools used to include<https://issues.apache.org/jira/browse/AVRO-758> log4j config.


-Isaac Levy
OS X el cap, java 1.8.0_92

Re: stand alone avro-tools prints log4j warning

Posted by durp <du...@sbcglobal.net>.
So there are a couple of ways to skin this cat. I did this in zsh.

​1) Create a wrapper < I called mine "logdiscarder"

#!/bin/zsh
log4jArgs() {
  log4jPropsFile="/tmp/avro-tools.log4j.properties"
  if [[ ! -a "$log4jPropsFile" ]]; then
    tmpProps=$(mktemp $log4jPropsFile)
    echo "log4j.rootLogger=INFO, devnull" >> $tmpProps
    echo "log4j.appender.devnull=org.apache.log4j.varia.NullAppender" >>
$tmpProps
  fi
  log4jprops="-Dlog4j.configuration=file:$log4jPropsFile"
}
MYSELF=`which "$0" 2>/dev/null`
[ $? -gt 0 -a -f "$0" ] && MYSELF="./$0"
log4jArgs
java_args+=$log4jprops
java=java
if [[ -a "$JAVA_HOME" ]]; then
  java="$JAVA_HOME/bin/java"
fi
exec "$java" $java_args -jar $MYSELF "$@"
exit 1

2) Wrap it around the jar:

cat nullifier avro-tools-1.8.1.jar > avro-tools && chmod 777 avro-tools

3) Put in your path and then enjoy a log noise and java -jar free avro
tools:

avro-tools getschema <myavrofile.avro> 



--
View this message in context: http://apache-avro.679487.n3.nabble.com/stand-alone-avro-tools-prints-log4j-warning-tp4035985p4036343.html
Sent from the Avro - Developers mailing list archive at Nabble.com.

Re: stand alone avro-tools prints log4j warning

Posted by Isaac Levy <Is...@coxautoinc.com>.
Doesn't work, unfortunately. Looks like the warning is emitted in hadoop fs api -- perhaps the java properties aren't propogated.

In any case, isn't this a bug in the avro-tools jar?

-Isaac


PS. The hadoop fs api has other counter-intuitive behavior, causing issues like:
$ avro-tools cat *.avro /dev/null
Exception in thread "main" java.io.FileNotFoundException: /dev/.null.crc (Permission denied)

(which would have been useful to count records)

On Oct 12, 2016, at 11:11 PM, radai <ra...@gmail.com>> wrote:

reading the doc page (http://logging.apache.org/log4j/1.2/faq.html#noconfig),
there's a log4j.defaultInitOverride property. have you tried adding
-Dlog4j.defaultInitOverride=true to your command line ?

On Wed, Oct 12, 2016 at 11:29 AM, Isaac Levy <Is...@coxautoinc.com>>
wrote:

Is there any way to silence these?

$ java -jar avro-tools-1.8.1.jar tojson foo
log4j:WARN No appenders could be found for logger
(org.apache.hadoop.metrics2.lib.MutableMetricsFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for
more info.

Looks like avro-tools used to include<https://issues.apache.
org/jira/browse/AVRO-758> log4j config.


-Isaac Levy
OS X el cap, java 1.8.0_92



Re: stand alone avro-tools prints log4j warning

Posted by radai <ra...@gmail.com>.
reading the doc page (http://logging.apache.org/log4j/1.2/faq.html#noconfig),
there's a log4j.defaultInitOverride property. have you tried adding
-Dlog4j.defaultInitOverride=true to your command line ?

On Wed, Oct 12, 2016 at 11:29 AM, Isaac Levy <Is...@coxautoinc.com>
wrote:

> Is there any way to silence these?
>
> $ java -jar avro-tools-1.8.1.jar tojson foo
> log4j:WARN No appenders could be found for logger
> (org.apache.hadoop.metrics2.lib.MutableMetricsFactory).
> log4j:WARN Please initialize the log4j system properly.
> log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for
> more info.
>
> Looks like avro-tools used to include<https://issues.apache.
> org/jira/browse/AVRO-758> log4j config.
>
>
> -Isaac Levy
> OS X el cap, java 1.8.0_92
>