我使用log4j编写了hadoop程序,并给出了它的部分
package org.myorg;
import java.io.*;
import java.util.*;
import org.apache.hadoop.fs.*;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapred.*;
import org.apache.hadoop.util.*;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.log4j.xml.DOMConfigurator;
public class ParallelIndexation {
//public static native long Traveser(String Path);
//public static native void Configure(String Path);
//static {
// System.loadLibrary("nativelib");
//}
public static class Map extends MapReduceBase implements
Mapper<LongWritable, Text, Text, LongWritable> {
private final static LongWritable zero = new LongWritable(0);
private Text word = new Text();
private static final Logger logger = LogManager.getLogger(Map.class.getName());
DOMConfigurator.configure("/export/hadoop-1.0.1/log4j.xml");
我尝试通过命令
编译hadoop程序root@one:/opt/jdk1.7.0_06/bin#. / javac - classpath/export/hadoop-1.0.1/hadoop-core-1.0.1.jar:/export/hadoop-1.0.1/log4j-1.2.17.jar - d/folder/classes/folder/src/ParallelIndexation.java
我也收到了以下错误消息
/folder/src/ParallelIndexation.java:27: error: <identifier> expected
DOMConfigurator.configure("/export/hadoop-1.0.1/log4j.xml");
^
/folder/src/ParallelIndexation.java:27: error: illegal start of type
DOMConfigurator.configure("/export/hadoop-1.0.1/log4j.xml");
^
2 errors
帮助消除这些错误。
答案 0 :(得分:1)
声明
DOMConfigurator.configure("/export/hadoop-1.0.1/log4j.xml");
应该在方法(或构造函数或static
初始化程序)
而不是Map