Logging errors and debug messages I'm currently working on a small project that uses Java to handle a socket-based MMO browser game. I'm still at the beginning of the project and I'm currently writing a class that logs errors and debug messages to the console and writes these to the appropriate file, based on the error.

I'm wondering if this code is clean, efficient, readable, and amendable in any way shape or form.

package nl.finicky.lemonade.core;
import nl.finicky.lemonade.Lemonade;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class Console {
    public static final String ANSI_RESET = "\u001B[0m";
    public static final String ANSI_BRIGHT = "\u001B[1m";
    public static final String ANSI_BLACK = "\u001B[30m";
    public static final String ANSI_RED = "\u001B[31m";
    public static final String ANSI_GREEN = "\u001B[32m";
    public static final String ANSI_YELLOW = "\u001B[33m";
    public static final String ANSI_BLUE = "\u001B[34m";
    public static final String ANSI_PURPLE = "\u001B[35m";
    public static final String ANSI_CYAN = "\u001B[36m";
    public static final String ANSI_WHITE = "\u001B[37m";
    private static File debug = new File("logs//debug.txt");
    private static File packets = new File("logs//packets.txt");
    private static File errors = new File("logs//errors.txt");

    private static PrintWriter debugWriter;
    private static PrintWriter packetWriter;
    private static PrintWriter errorWriter;

    public Console() {
        try {
            if (!debug.exists()) {
                debug.createNewFile();
            }

            if (!packets.exists()) {
                packets.createNewFile();
            }

            if (!errors.exists()) {
                errors.createNewFile();
            }

            debugWriter = new PrintWriter(new FileWriter(debug));
            packetWriter = new PrintWriter(new FileWriter(packets));
            errorWriter = new PrintWriter(new FileWriter(errors));
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    public void start(Object message) {
        if (Lemonade.getConfiguration().getBool("logging.debug")) {
            debugWriter.write(Lemonade.getDate() + message.toString() + "\r\n");
        }

        System.out.println(ANSI_GREEN + ANSI_BRIGHT + "[START] " + message.toString() + ANSI_RESET);
    }
    public void user(Object message) {
        if (Lemonade.getConfiguration().getBool("logging.debug")) {
            debugWriter.write(Lemonade.getDate() + message.toString() + "\r\n");
        }

        System.out.println(ANSI_BLUE + "[USER] " + message.toString() + ANSI_RESET);
    }

    public void shutdown(Object message) {
        if (Lemonade.getConfiguration().getBool("logging.debug")) {
            debugWriter.write(Lemonade.getDate() + message.toString() + "\r\n");
        }
        System.out.println(ANSI_YELLOW + ANSI_BRIGHT + "[SHUTDOWN] " + message.toString() + ANSI_RESET);
    }

    public synchronized void error(Object message) {
        errorWriter.write(Lemonade.getDate() + message.toString() + "\r\n");
        System.out.println(ANSI_RED + "[ERROR] " + message.toString() + ANSI_RESET);
    }

    public synchronized void critical(Object message) {
        errorWriter.write(Lemonade.getDate() + message.toString() + "\r\n");
        System.out.println(ANSI_RED + "[ERROR] " + message.toString() + ANSI_RESET);
    }

    public synchronized void debug(Object message) {
        if (Lemonade.getConfiguration().getBool("logging.debug")) {
            debugWriter.write(Lemonade.getDate() + message.toString() + "\r\n");
        }

        System.out.println(ANSI_PURPLE + "[DEBUG] " + message.toString() + ANSI_RESET);
    }

    public synchronized void packet(Object message)
    {
        System.out.println(ANSI_BLUE + "[PACKET] " + message.toString() + ANSI_RESET);

        if(Lemonade.getConfiguration().getBool("logging.packets"))
        {
            packetWriter.write(Lemonade.getDate() + message.toString() + "\r\n");
        }
    }
}
A synchronized method will block execution of other methods in the class, you better use a seperate thread to store the logsentries to write.

This could be a simple write-only-thread.

.error and .critical are the same, this is violating DRY.