Code example for PrintWriter

Methods: flush

0
		sb.append("-> ");
		sb.append(record.getMessage());
		sb.append("\n");
		if (record.getThrown() != null) {
			StringWriter sw = new StringWriter();
			PrintWriter out = new PrintWriter(sw);
			record.getThrown().printStackTrace(out);
			out.flush();
			sb.append(sw.toString());
		} 
		return sb.toString();
	} 
 
	public static final JavaLoggingFormatter INSTANCE = new JavaLoggingFormatter();
 
	public static void install() { 
		Handler[] handler = Logger.getLogger("").getHandlers();
		for (int i = 0; i < handler.length; i++) {
			handler[i].setFormatter(INSTANCE);
		} 
	}