public void saveLog() {
   File file = new File("." + File.separator);
   String logFile = null;
   try {
     logFile =
         RapidMinerGUI.getMainFrame()
             .getProcess()
             .getRootOperator()
             .getParameterAsString(ProcessRootOperator.PARAMETER_LOGFILE);
   } catch (UndefinedParameterError ex) {
     // tries to use process file name for initialization
   }
   if (logFile != null) {
     file = RapidMinerGUI.getMainFrame().getProcess().resolveFileName(logFile);
   }
   file = SwingTools.chooseFile(RapidMinerGUI.getMainFrame(), file, false, "log", "log file");
   if (file != null) {
     PrintWriter out = null;
     try {
       out = new PrintWriter(new FileWriter(file));
       out.println(textArea.getText());
     } catch (IOException ex) {
       SwingTools.showSimpleErrorMessage("cannot_write_log_file", ex);
     } finally {
       if (out != null) {
         out.close();
       }
     }
   }
 }
  private synchronized void append(LogRecord record) {
    Document doc = textArea.getStyledDocument();
    String formatted = formatter.format(record);

    if (record.getLevel().intValue() >= Level.SEVERE.intValue()) {
      StyleConstants.setForeground(attributeSet, COLOR_ERROR);
      StyleConstants.setBold(attributeSet, true);
    } else if (record.getLevel().intValue() >= Level.WARNING.intValue()) {
      StyleConstants.setForeground(attributeSet, COLOR_WARNING);
      StyleConstants.setBold(attributeSet, true);
    } else if (record.getLevel().intValue() >= Level.INFO.intValue()) {
      StyleConstants.setForeground(attributeSet, COLOR_INFO);
      StyleConstants.setBold(attributeSet, false);
    } else {
      StyleConstants.setForeground(attributeSet, COLOR_DEFAULT);
      StyleConstants.setBold(attributeSet, false);
    }

    try {
      doc.insertString(doc.getLength(), formatted, attributeSet);
    } catch (BadLocationException e) {
      // cannot happen
      // rather dump to stderr than logging and having this method called back
      e.printStackTrace();
    }

    if (maxRows >= 0) {
      int removeLength = 0;
      while (lineLengths.size() > maxRows) {
        removeLength += lineLengths.removeFirst();
      }
      try {
        doc.remove(0, removeLength);
      } catch (BadLocationException e) {
        SwingTools.showSimpleErrorMessage("error_during_logging", e);
      }
    }
    textArea.setCaretPosition(textArea.getDocument().getLength());
  }