Java Log to File logError(String message)

Here you can find the source of logError(String message)

Description

log Error

License

Open Source License

Declaration

static void logError(String message) 

Method Source Code

//package com.java2s;
// it under the terms of the GNU General Public License as published by

import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    static final SimpleDateFormat _DateFormatter = new SimpleDateFormat("HH:mm:ss:SSS");
    private static final PrintStream err = System.err;
    private static boolean sendConsoleOutputToTwsLog = false;

    static void logError(String message) {
        getErrStream().println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
        getErrStream().println(formatMessage(message));
        getErrStream().println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
    }/*ww w . java 2 s .c o  m*/

    static PrintStream getErrStream() {
        if (sendConsoleOutputToTwsLog) {
            return System.err;
        } else {
            return err;
        }
    }

    private static String formatMessage(String message) {
        return _DateFormatter.format(new Date()) + " IBController: " + message;
    }
}

Related

  1. log(String msg)
  2. log(String msg)
  3. log(String name, String message)
  4. log(String tag, T msg)
  5. logError(ILog log, String message)
  6. logError(String msg)
  7. logErrPrint(String s)
  8. logger(String s)
  9. loggerOld(String s)