import java.util.*;\r
\r
import java.net.*;\r
+import org.apache.log4j.Logger;\r
+import org.apache.log4j.SimpleLayout;\r
+import org.apache.log4j.Level;\r
+import org.apache.log4j.ConsoleAppender;\r
\r
\r
/**\r
* <br><br>Current properties include:\r
* <br>logs.Axis.Level - one of the stringified Levels for log4j controlling the logging level for axis (used for web services)\r
* <br>logs.Castor.Level - one of the stringified Levels for log4j controlling the logging level for castor (used for serialization)\r
- * <br>logs.Jalview.Level - Jalview.log stringified level.\r
+ * <br>logs.Jalview.Level - Cache.log stringified level.\r
* <br>DISCOVERY_START - Boolean - controls if discovery services are queried on startup\r
* <br>DISCOVERY_URLS - comma separated list of Discovery Service endpoints.\r
* <br>SCREEN_WIDTH,SCREEN_HEIGHT,SCREEN_Y=285,SCREEN_X=371,SHOW_FULLSCREEN\r
*/\r
public class Cache\r
{\r
+ /**\r
+ * Initialises the Apache Axis logger\r
+ */\r
+ public static Logger log;\r
\r
/** Jalview Properties */\r
public static Properties applicationProperties = new Properties();\r
/** Default file is ~/.jalview_properties */\r
static String propertiesFile;\r
\r
+ public static void initLogger()\r
+ {\r
+ try\r
+ {\r
+ Logger laxis = Logger.getLogger("org.apache.axis");\r
+ Logger lcastor = Logger.getLogger("org.exolab.castor");\r
+ jalview.bin.Cache.log = Logger.getLogger("jalview.bin.Jalview");\r
+\r
+ laxis.setLevel(Level.toLevel(Cache.getDefault("logs.Axis.Level",\r
+ Level.INFO.toString())));\r
+ lcastor.setLevel(Level.toLevel(Cache.getDefault("logs.Castor.Level",\r
+ Level.INFO.toString())));\r
+ jalview.bin.Cache.log.setLevel(Level.toLevel(Cache.getDefault(\r
+ "logs.Jalview.level",\r
+ Level.INFO.toString())));\r
+\r
+ ConsoleAppender ap = new ConsoleAppender(new SimpleLayout(),\r
+ "System.err");\r
+ ap.setName("JalviewLogger");\r
+\r
+ laxis.addAppender(ap);\r
+ lcastor.addAppender(ap);\r
+ jalview.bin.Cache.log.addAppender(ap);\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ System.err.println("Problems initializing the log4j system\n");\r
+ }\r
+ }\r
+\r
+\r
/** Called when Jalview is started */\r
public static void loadProperties(String propsFile)\r
{\r
*/\r
public class Jalview\r
{\r
- /**\r
- * Initialises the Apache Axis logger\r
- */\r
- public static Logger log;\r
- private static void initLogger()\r
- {\r
- Logger laxis = Logger.getLogger("org.apache.axis");\r
- Logger lcastor = Logger.getLogger("org.exolab.castor");\r
- log = Logger.getLogger("jalview.bin.Jalview");\r
-\r
- laxis.setLevel(Level.toLevel(Cache.getDefault("logs.Axis.Level", Level.INFO.toString())));\r
- lcastor.setLevel(Level.toLevel(Cache.getDefault("logs.Castor.Level", Level.INFO.toString())));\r
- log.setLevel(Level.toLevel(Cache.getDefault("logs.Jalview.level", Level.INFO.toString())));\r
-\r
- ConsoleAppender ap = new ConsoleAppender(new SimpleLayout(),\r
- "System.err");\r
- ap.setName("JalviewLogger");\r
-\r
- laxis.addAppender(ap);\r
- lcastor.addAppender(ap);\r
- log.addAppender(ap);\r
- }\r
\r
/**\r
* main class for Jalview application\r
headless = true;\r
}\r
\r
- Cache.loadProperties(aparser.getValue("props"));\r
-\r
- try\r
- {\r
- initLogger();\r
- }\r
- catch (Exception e)\r
- {\r
- System.err.println("Problems initializing the log4j system\n");\r
- }\r
+ try\r
+ {\r
+ Cache.initLogger();\r
+ }\r
+ catch (java.lang.NoClassDefFoundError error)\r
+ {\r
+ error.printStackTrace();\r
+ System.out.println(\r
+ "\nEssential logging libraries not found."\r
+ +"\nUse: java -Djava.ext.dirs=$PATH_TO_LIB$ jalview.bin.Jalview");\r
+ System.exit(0);\r
+ }\r
\r
+ Cache.loadProperties(aparser.getValue("props"));\r
\r
Desktop desktop = null;\r
if( !headless )\r
}
catch (Exception ex)
{
- jalview.bin.Jalview.log.error(
+ jalview.bin.Cache.log.error(
"Serious! Service location failed\nfor URL :" + WsURL +
"\n", ex);
if (!urls.contains(u))
urls.add(u);
else
- jalview.bin.Jalview.log.info("Ignoring duplicate url in DISCOVERY_URLS list");
+ jalview.bin.Cache.log.info("Ignoring duplicate url in DISCOVERY_URLS list");
}
catch (Exception ex)
{
- jalview.bin.Jalview.log.warn(
+ jalview.bin.Cache.log.warn(
"Problem whilst trying to make a URL from '" +
( (url != null) ? url : "<null>")+"'");
- jalview.bin.Jalview.log.warn("This was probably due to a malformed comma separated list"
+ jalview.bin.Cache.log.warn("This was probably due to a malformed comma separated list"
+" in the DISCOVERY_URLS entry of $(HOME)/.jalview_properties)");
- jalview.bin.Jalview.log.debug("Exception was ",ex);
+ jalview.bin.Cache.log.debug("Exception was ",ex);
}
}
}catch(Exception ex)
- {jalview.bin.Jalview.log.warn("Error parsing comma separated list of urls in DISCOVERY_URLS.",ex);}
+ {jalview.bin.Cache.log.warn("Error parsing comma separated list of urls in DISCOVERY_URLS.",ex);}
if (urls.size()>0)
return urls;
return null;
}
else
{
- jalview.bin.Jalview.log.debug("Setting default services");
+ jalview.bin.Cache.log.debug("Setting default services");
services = new Hashtable();
// Muscle, Clustal and JPred.
ServiceHandle[] defServices = {
ServiceHandles shs = null;
try
{
- jalview.bin.Jalview.log.debug("Discovering services using " + location);
+ jalview.bin.Cache.log.debug("Discovering services using " + location);
shs = locateWebService(location).getServices();
}
catch (Exception e)
{
- jalview.bin.Jalview.log.debug("No Discovery service at " +
+ jalview.bin.Cache.log.debug("No Discovery service at " +
location);
- jalview.bin.Jalview.log.debug(e);
+ jalview.bin.Cache.log.debug(e);
}
if ( (shs != null) && shs.getServices().length > 0)
{
if (!cat.contains(sh[i]))
{
- jalview.bin.Jalview.log.debug("A " + sh[i].getAbstractName() +
+ jalview.bin.Cache.log.debug("A " + sh[i].getAbstractName() +
" service called " +
sh[i].getName() + " exists at " +
sh[i].getEndpointURL() + "\n");
disc_serv = new java.net.URL(sh[i].getEndpointURL());
if (!ServiceURLList.contains(disc_serv))
{
- jalview.bin.Jalview.log.debug(
+ jalview.bin.Cache.log.debug(
"Adding new discovery service at " + disc_serv);
ServiceURLList.add(disc_serv);
seenNewDiscovery = true;
}
catch (Exception e)
{
- jalview.bin.Jalview.log.debug(
+ jalview.bin.Cache.log.debug(
"Ignoring bad discovery service URL " + sh[i].getEndpointURL(),
e);
}
int s_url = 0;
if (ServiceURLList==null)
{
- jalview.bin.Jalview.log.debug("No service endpoints to use for service discovery.");
+ jalview.bin.Cache.log.debug("No service endpoints to use for service discovery.");
return;
}
while (s_url < ServiceURLList.size())
buildServiceLists(sh, cat, sscat);
} else {
- jalview.bin.Jalview.log.warn(
+ jalview.bin.Cache.log.warn(
"No services at "
+((java.net.URL) ServiceURLList.get(s_url))
+" - check DISCOVERY_URLS property in .jalview_properties");
"Timed out when communicating with server\nTry again later.\n"));\r
}\r
if (result.getState()==0)\r
- jalview.bin.Jalview.log.debug("Finished "+jobId);\r
+ jalview.bin.Cache.log.debug("Finished "+jobId);\r
if (result.isRunning())\r
{\r
wsInfo.setStatus(WebserviceInfo.STATE_RUNNING);\r
"JPredWS Client: Failed to submit the prediction (Possibly a server error - see below)\n" +\r
e.getMessage() + "\n");\r
\r
- jalview.bin.Jalview.log.debug("Failed Submission",e);\r
+ jalview.bin.Cache.log.debug("Failed Submission",e);\r
}\r
}\r
\r
\r
try\r
{\r
- jalview.bin.Jalview.log.debug("Parsing output from JNet job.");\r
+ jalview.bin.Cache.log.debug("Parsing output from JNet job.");\r
// JPredFile prediction = new JPredFile("C:/JalviewX/files/jpred.txt", "File");\r
jalview.io.JPredFile prediction = new jalview.io.JPredFile(result.\r
getPredfile(),\r
"Paste");\r
SequenceI[] preds = prediction.getSeqsAsArray();\r
- jalview.bin.Jalview.log.debug("Got prediction profile.");\r
+ jalview.bin.Cache.log.debug("Got prediction profile.");\r
Alignment al;\r
int FirstSeq; // the position of the query sequence in Alignment al\r
boolean noMsa = true; // set if no MSA has been returned by JPred\r
\r
if ( (this.msa != null) && (result.getAligfile() != null))\r
{\r
- jalview.bin.Jalview.log.debug("Getting associated alignment.");\r
+ jalview.bin.Cache.log.debug("Getting associated alignment.");\r
// we ignore the returned alignment if we only predicted on a single sequence\r
String format = jalview.io.IdentifyFile.Identify(result.getAligfile(),\r
"Paste");\r
*/\r
\r
wsInfo.setProgressText(OutputHeader);\r
- jalview.bin.Jalview.log.debug("Finished parsing output.");\r
+ jalview.bin.Cache.log.debug("Finished parsing output.");\r
AlignFrame af = new AlignFrame(al);\r
\r
Desktop.addInternalFrame(af, altitle,\r
}\r
catch (Exception ex)\r
{\r
- jalview.bin.Jalview.log.warn("Exception whilst parsing JNet style secondary structure prediction.");\r
- jalview.bin.Jalview.log.debug("Exception: ",ex);\r
+ jalview.bin.Cache.log.warn("Exception whilst parsing JNet style secondary structure prediction.");\r
+ jalview.bin.Cache.log.debug("Exception: ",ex);\r
}\r
}\r
}\r
throw (new Exception(\r
"Timed out when communicating with server\nTry again later.\n"));\r
}\r
- jalview.bin.Jalview.log.debug("Result state " + result.getState() +\r
+ jalview.bin.Cache.log.debug("Result state " + result.getState() +\r
"(ServerError=" + result.isServerError() +\r
")");\r
if (result.isRunning())\r