X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FCache.java;h=9702a9231b54e9976e54ef77130d8ef0fa8007c5;hb=cb8ec179c020265666678572815ab056a024da22;hp=8fae6a900ab3d3fb5fee480c4c96329b5a759ba8;hpb=3ca1aeccca8d3adfd55d1ff8bd447f8bf0d4ac2f;p=jalview.git diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 8fae6a9..9702a92 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -22,7 +22,10 @@ import java.io.*; import java.util.*; -import java.net.*; +import org.apache.log4j.Logger; +import org.apache.log4j.SimpleLayout; +import org.apache.log4j.Level; +import org.apache.log4j.ConsoleAppender; /** @@ -30,6 +33,9 @@ import java.net.*; *

Current properties include: *
logs.Axis.Level - one of the stringified Levels for log4j controlling the logging level for axis (used for web services) *
logs.Castor.Level - one of the stringified Levels for log4j controlling the logging level for castor (used for serialization) + *
logs.Jalview.Level - Cache.log stringified level. + *
DISCOVERY_START - Boolean - controls if discovery services are queried on startup + *
DISCOVERY_URLS - comma separated list of Discovery Service endpoints. *
SCREEN_WIDTH,SCREEN_HEIGHT,SCREEN_Y=285,SCREEN_X=371,SHOW_FULLSCREEN * FONT_NAME,FONT_SIZE,FONT_STYLE,GAP_SYMBOL,LAST_DIRECTORY,USER_DEFINED_COLOUR * SHOW_FULL_ID,SHOW_IDENTITY,SHOW_QUALITY,SHOW_ANNOTATIONS,SHOW_CONSERVATION, @@ -40,6 +46,10 @@ import java.net.*; */ public class Cache { + /** + * Initialises the Apache Axis logger + */ + public static Logger log; /** Jalview Properties */ public static Properties applicationProperties = new Properties(); @@ -47,6 +57,38 @@ public class Cache /** Default file is ~/.jalview_properties */ static String propertiesFile; + public static void initLogger() + { + try + { + Logger laxis = Logger.getLogger("org.apache.axis"); + Logger lcastor = Logger.getLogger("org.exolab.castor"); + jalview.bin.Cache.log = Logger.getLogger("jalview.bin.Jalview"); + + laxis.setLevel(Level.toLevel(Cache.getDefault("logs.Axis.Level", + Level.INFO.toString()))); + lcastor.setLevel(Level.toLevel(Cache.getDefault("logs.Castor.Level", + Level.INFO.toString()))); + jalview.bin.Cache.log.setLevel(Level.toLevel(Cache.getDefault( + "logs.Jalview.level", + Level.INFO.toString()))); + ConsoleAppender ap = new ConsoleAppender(new SimpleLayout(), + "System.err"); + ap.setName("JalviewLogger"); + + laxis.addAppender(ap); + lcastor.addAppender(ap); + jalview.bin.Cache.log.addAppender(ap); + // Tell the user that debug is enabled + jalview.bin.Cache.log.debug("Jalview Debugging Output Follows."); + } + catch (Exception ex) + { + System.err.println("Problems initializing the log4j system\n"); + } + } + + /** Called when Jalview is started */ public static void loadProperties(String propsFile) { @@ -114,6 +156,7 @@ public class Cache System.out.println("Jalview Version: "+codeVersion); + // jnlpVersion will be null if we're using InstallAnywhere // Dont do this check if running in headless mode if(jnlpVersion==null && ( @@ -121,7 +164,6 @@ public class Cache || System.getProperty("java.awt.headless").equals("false"))) { - class VersionChecker extends Thread { @@ -161,7 +203,10 @@ public class Cache } else { - setProperty("LATEST_VERSION", jnlpVersion); + if(jnlpVersion!=null) + setProperty("LATEST_VERSION", jnlpVersion); + else + applicationProperties.remove("LATEST_VERSION"); } setProperty("VERSION", codeVersion); @@ -234,7 +279,7 @@ public class Cache out.close(); } catch (Exception ex) - { } + { System.out.println("Error setting property: "+key+" "+obj+"\n"+ex); } return obj; } @@ -247,6 +292,6 @@ public class Cache out.close(); } catch (Exception ex) - { } + { System.out.println("Error saving properties: "+ex); } } }