package com.utils;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
public class LoggerUtils {
private static final String logDir = "/logs";
public static void log(String className, String log) throws IOException {
FileSystem fs = FileSystem.get(new Configuration());
Path file = new Path(logDir + "/" + className);
FSDataOutputStream output = null;
if (!fs.exists(file)) {
output = fs.create(file);
} else {
output = fs.append(file);
}
output.writeUTF(log);
output.flush();
output.close();
}
}