import java.io.*; import java.text.*; import java.util.*; public class msglog { protected static String defaultLogFile = "/var/log/emonster.log"; public static void setDefaultLogFile( String s ) { defaultLogFile = s; } public static void write(String s) { write( defaultLogFile, s ); } public static void write( String f, String s ) { try { TimeZone tz = TimeZone.getTimeZone("PST"); // or EST, MID, etc ... Date now = new Date(); DateFormat df = new SimpleDateFormat ("yyyy-MM-dd kk:mm:ss "); df.setTimeZone(tz); String currentTime = df.format(now); FileWriter aWriter = new FileWriter(f, true); aWriter.write(currentTime + " " + s + System.getProperty("line.separator")); // System.out.println( s ); aWriter.flush(); aWriter.close(); } catch (IOException ioe) { // I/O error ioe.printStackTrace(); return; } } }