Pig Batch模式:如何设置日志级别以隐藏INFO日志消息?

时间:2013-05-18 18:45:56

标签: apache-pig

使用Apache Pig版本0.10.1.21 (rexported)。当我执行一个pig脚本时,有很多INFO记录行看起来像这样:

2013-05-18 14:30:12,810 [Thread-28] INFO  org.apache.hadoop.mapred.Task - Task 'attempt_local_0005_r_000000_0' done.
2013-05-18 14:30:18,064 [main] WARN  org.apache.pig.tools.pigstats.PigStatsUtil - Failed to get RunningJob for job job_local_0005
2013-05-18 14:30:18,094 [Thread-31] WARN  org.apache.hadoop.mapred.JobClient - No job jar file set.  User classes may not be found. See JobConf(Class) or JobConf#setJar(String).
2013-05-18 14:30:18,114 [Thread-31] INFO  org.apache.hadoop.mapreduce.lib.input.FileInputFormat - Total input paths to process : 1
2013-05-18 14:30:18,254 [Thread-32] INFO  org.apache.hadoop.mapred.Task -  Using ResourceCalculatorPlugin : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@3fcb2dd1
2013-05-18 14:30:18,265 [Thread-32] INFO  org.apache.hadoop.mapred.MapTask - io.sort.mb = 10

pig脚本中是否有SET命令或命令行标志以允许记录级别?基本上我想隐藏[Thread-xx] INFO消息。仅显示警告和错误。我试过命令行调试标志。不幸的是,INFO消息仍然显示出来:

pig -x local -d WARN MyScript.pig

希望有一个解决方案。提前感谢您的帮助。

已解决:回答by Loran Bendig, set the log4j.properties。为方便起见,这里总结了

步骤1:将log4j配置文件复制到我的猪脚本所在的文件夹中。

cp /etc/pig/conf.dist/log4j.properties log4j_WARN

步骤2:编辑log4j_WARN文件并确保这两行存在

log4j.logger.org.apache.pig=WARN, A
log4j.logger.org.apache.hadoop = WARN, A

步骤3:运行pig脚本并指示它使用自定义log4j

pig -x local -4 log4j_WARN MyScript.pig

3 个答案:

答案 0 :(得分:3)

另一个设置也可能是这样的:

创建名为nolog.conf的文件,其中包含以下内容

try{
            $dbConnect = new PDO($dbConnect, $username, $password);
        } catch (PDOException $error) {
            echo 'Error Connecting: ' . $error->getMessage();
        }

        $reg = $dbConnect->prepare('INSERT INTO `user` (
            `userID`, 
            `firstName`, 
            `lastName`, 
            `title`, 
            `suffix`, 
            `suffixTwo`, 
            `email`, 
            `employer`, 
            `expertise`, 
            `primaryAddress`, 
            `secondaryAddress`, 
            `primaryPhone`, 
            `secondaryPhone`, 
            `city`, 
            `postalCode`, 
            `hash`
            )

            VALUES (
            NULL,
            :firstName, 
            :lastName, 
            :title, 
            :suffixOne, 
            :suffixTwo, 
            :email, 
            :employer, 
            :expertise, 
            :primaryAddress, 
            :secondaryAddress, 
            :primaryPhone, 
            :secondaryPhone, 
            :city, 
            :zip, 
            :hash
            )');

        $reg->bindValue(":firstName", $firstName);
        $reg->bindValue(":lastName", $lastName);
        $reg->bindValue(":title", $title);
        $reg->bindValue(":suffixOne", $suffixOne);
        $reg->bindValue(":suffixTwo", $suffixTwo);
        $reg->bindValue(":email", $email);
        $reg->bindValue(":employer", $employer);
        $reg->bindValue(":expertise", $expertise);
        $reg->bindValue(":hash", $hash);
        $reg->bindValue(":primaryAddress", $primaryAddress);
        $reg->bindValue(":secondaryAddress", $secondaryAddress);
        $reg->bindValue(":firstName", $firstName);
        $reg->bindValue(":city", $city);
        $reg->bindValue(":state", $state);
        $reg->bindValue(":zip", $zip);
        $reg->bindValue(":country", $country);
        $reg->bindValue(":primaryPhone", $primaryPhone);
        $reg->bindValue(":secondaryPhone", $secondaryPhone);
        $reg->execute();

然后运行pig如下

log4j.rootLogger=fatal

答案 1 :(得分:0)

您可以覆盖默认日志配置(包括INFO消息),如下所示:

pig -4 log4j.properties MyScript.pig

答案 2 :(得分:0)

您还需要设置rootLogger:

log4j.rootLogger=ERROR, A
log4j.logger.org.apache.pig=ERROR, A
log4j.logger.org.apache.hadoop = ERROR, A