static synchronized void setFilename(String filename) {

		if(writer != null) {
			try {
				writer.close();
				writer = null;
			} catch (IOException e) {
				System.out.println("Unable to close log file");
			}
		}

		if(filename == null) {
			writer = null;
			return;
		}

		FileWriter out = null;
		try {
			out = new FileWriter(filename);
		} catch (IOException e) {
			System.out.println("Unable to open log file: " + filename);
			writer = null;
			return;
		}
		if(out != null) {
			writer = new BufferedWriter(out);
		} 
	}