Java Log to File log(String message, Exception e)

Here you can find the source of log(String message, Exception e)

Description

log

License

Open Source License

Declaration

public static void log(String message, Exception e) 

Method Source Code


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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static int log_level = 3;
    public final static int LOG_DEFAULT = 1;
    public final static int LOG_ERRORS = 2;

    public static void log(String message) {
        log(message, "");
    }/*from   ww w . j a va  2  s. c o m*/

    public static void log(String message, Exception e) {
        log(message, "", e);
    }

    public static void log(String message, String ref, Exception e) {
        log(message, ref);
        log(e);
    }

    public static void log(String message, String ref) {
        if (log_level >= LOG_DEFAULT) {
            System.out.println((ref.equals("") ? "MOSS" : ref) + " "
                    + new SimpleDateFormat("HH:mm:ss").format(new Date()) + "> " + message);
        }
    }

    public static void log(Exception e) {
        if (log_level >= LOG_ERRORS) {
            e.printStackTrace();
        }
    }
}

Related

  1. log(Level level, String methodName, Object message)
  2. log(String message)
  3. log(String message)
  4. log(String message)
  5. log(String method, String message)
  6. log(String msg)
  7. log(String msg)
  8. log(String name, String message)