Can we use log4j to log in mapreduce? If so, provide the steps to use log4j in map-reduce to log the information. I have written the below log4.properties but, nothing was logged.
Asked
Active
Viewed 572 times
1 Answers
0
Here is one simple way to configure the Log4j in Mapper, just for
Standard practices for logging in MapReduce jobs
and the code snippet goes here
import org.apache.log4j.Logger; // other imports omitted
public class SampleMapper extends Mapper { private Logger logger = Logger.getLogger(SampleMapper.class);
@Override
protected void setup(Context context) {
logger.info("Initializing NoSQL Connection.")
try {
// logic for connecting to NoSQL - ommitted
} catch (Exception ex) {
logger.error(ex.getMessage());
}
}
@Override
protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
// mapper code ommitted
}
}
Sorry for formatting.