Java Log to File logToFile(String string, String logFile)

Here you can find the source of logToFile(String string, String logFile)

Description

log To File

License

Open Source License

Declaration

public static void logToFile(String string, String logFile) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.FileWriter;
import java.io.IOException;

public class Main {
    public static void logToFile(String string, String logFile) {
        logToFile(string, logFile, true, true);
    }/*  w  w w. j  ava  2s  .  c  o  m*/

    public static void logToFile(String string, String logFile, boolean append, boolean consoleprint) {
        if (consoleprint)
            System.out.println(string);
        FileWriter out = null;
        try {
            out = new FileWriter(logFile, append);
            out.write("\n");
            out.write(string);
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Related

  1. logger(String s)
  2. loggerOld(String s)
  3. logInfo(ILog log, String message)
  4. logRecordToString(LogRecord record)
  5. logToFile(String filePath, String message)
  6. logToFile(String what, String where)