/* * DasLogger.java * * Created on June 6, 2005, 12:12 PM */ package org.das2.system; import org.das2.DasApplication; import java.io.*; import java.net.MalformedURLException; import java.net.URL; import java.text.MessageFormat; import java.util.logging.*; /** * * @author Jeremy */ public class DasLogger { public static final boolean DISABLE_RELOAD= true; public static void reload() throws IOException { try { if ( DISABLE_RELOAD ) return; java.net.URL logConfigURL; File local; if ( DasApplication.getProperty("user.name","applet").equals("Web") ) { local= new File("/tmp"); } else if ( DasApplication.getProperty("user.name","applet").equals("applet") ) { return; } else { local= new File( DasApplication.getProperty("user.home","applet") ); } File userDirectory=new File( local, ".das2" ); File localLogConfig= new File( userDirectory, "logging.properties" ); if ( localLogConfig.exists() ) { Logger.getLogger("").info("using "+localLogConfig); logConfigURL= localLogConfig.toURI().toURL(); } else { logConfigURL= DasLogger.class.getResource("logging.properties"); } if ( logConfigURL==null ) { System.err.println("unable to locate logging properties file logging.properties, using defaults"); } else { //dumpUrl(logConfigURL); InputStream in= logConfigURL.openStream(); LogManager.getLogManager().readConfiguration( in ); in.close(); //System.err.println( "read log configuration from "+logConfigURL ); //printStatus(); } } catch ( MalformedURLException e ) { throw new RuntimeException(e); // this shouldn't happen } } private static void dumpUrl( URL url ) throws IOException { BufferedReader reader= new BufferedReader( new InputStreamReader( url.openStream() ) ); String s= reader.readLine(); while( s!=null ) { System.out.println(s); s= reader.readLine(); } reader.close(); } public static void printStatus() { String[] loggers= new String[] { "", "das2.system", "das2.gui", "das2.graphics", "das2.dataOperations", "das2.dataTransfer", }; for ( int i=0; i