Package com.utils

Source Code of com.utils.LoggerUtils

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();
  }
}
TOP

Related Classes of com.utils.LoggerUtils

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.