Created
October 2, 2012 15:47
-
-
Save geofferyzh/3820300 to your computer and use it in GitHub Desktop.
Hadoop 101 - Debug using Log4J.Logger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get a handle on a Logger by putting something like this in your class | |
import org.apache.log4j.Logger; | |
... | |
public class Foo { | |
private static final Logger sLogger = Logger.getLogger(Foo.class); | |
... | |
} | |
// After you get a handle on the logger, within your class you can make logging calls at different levels. | |
sLogger.debug("Debug message"); | |
sLogger.info("Info message"); | |
sLogger.warn("Warn message"); | |
sLogger.error("Error message"); | |
sLogger.fatal("Fatal message"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import org.apache.hadoop.conf.Configuration; | |
import org.apache.hadoop.io.Text; | |
import org.apache.hadoop.mapreduce.Mapper; | |
import org.apache.log4j.Logger; | |
//public class SpreadActivatorMapper extends Mapper<LongWritable, Text, Text, Text> { | |
public class SAMapper extends Mapper<Text, VertexInfo, Text, VertexInfo> { | |
private static final Logger sLogger = Logger.getLogger(SAMapper.class); | |
// Map Task --------------------------------------------------------------------------- | |
public void map(Text key, VertexInfo value, Context context) throws IOException, InterruptedException { | |
// map task details omitted | |
sLogger.info("Emitting network pair: [" + key + ", " + value + "]"); | |
context.write(key, value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment