public DefaultHandler(boolean consoleLogging, String fileName)
        throws FreeColException {
        this.consoleLogging = consoleLogging;
        File file = new File(fileName);

        if (file.exists()) {
            if (file.isDirectory()) {
                throw new FreeColException("Log file \"" + fileName
                    + "\" could not be created.");
            } else if (file.isFile()) {
                file.delete();
            }
        }

        try {
            file.createNewFile();
        } catch (IOException e) {
            throw new FreeColException("Log file \"" + fileName
                + "\" could not be created: " + e.getMessage());
        }

        if (!file.canWrite()) {
            throw new FreeColException("Can not write in log file \""
                + fileName + "\".");
        }

        try {
            fileWriter = new FileWriter(file);
        } catch (IOException e) {
            throw new FreeColException("Can not write in log file \""
                + fileName + "\".");
        }

        // We should use XMLFormatter here in the future
        // or maybe a self-made HTMLFormatter.
        setFormatter(new TextFormatter());

        try {
            String str = "FreeCol game version: " + FreeCol.getRevision()
                + "\nFreeCol protocol version: "
                + DOMMessage.getFreeColProtocolVersion()
                + "\n\nJava vendor: " + System.getProperty("java.vendor")
                + "\nJava version: " + System.getProperty("java.version")
                + "\nJava WM name: " + System.getProperty("java.vm.name")
                + "\nJava WM vendor: " + System.getProperty("java.vm.vendor")
                + "\nJava WM version: " + System.getProperty("java.vm.version")
                + "\n\nOS name: " + System.getProperty("os.name")
                + "\nOS architecture: " + System.getProperty("os.arch")
                + "\nOS version: " + System.getProperty("os.version")
                + "\n\n";
            fileWriter.write(str, 0, str.length());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }