String log4jConfProp = ConfigurationManager.getProperty("dspace.dir") + File.separator + "config" + File.separator + "log4j.properties"; String log4jConfXml = ConfigurationManager.getProperty("dspace.dir") + File.separator + "config" + File.separator + "log4j.xml";  File xmlFile = new File(log4jConfXml); if (xmlFile.exists()) { try { DOMConfigurator.configure(xmlFile.toURL()); log.info("DSpace logging installed using log4j.xml"); } catch (MalformedURLException e) { PropertyConfigurator.configure(log4jConfProp); log.error("Logger failed to load log4j.xml, defaulted to " + "log4j.properties: " + e); } } else { PropertyConfigurator.configure(log4jConfProp); log.info("DSpace logging installed using log4j.properties"); }
    public void init()    {        // Get config parameter        String config = getServletContext().getInitParameter("dspace-config");        // Load in DSpace config        ConfigurationManager.loadConfig(config);        // Load the log4j config, if a log4j.xml version exists use that        // configuration format over the log4j.properties version        String log4jConfProp = ConfigurationManager.getProperty("dspace.dir")                         + File.separator + "config" + File.separator                         + "log4j.properties";        String log4jConfXml = ConfigurationManager.getProperty("dspace.dir")                        + File.separator + "config" + File.separator + "log4j.xml";                File xmlFile = new File(log4jConfXml);        if (xmlFile.exists())         {        	try             {        		DOMConfigurator.configure(xmlFile.toURL());                log.info("DSpace logging installed using log4j.xml");            }             catch (MalformedURLException e)             {            	PropertyConfigurator.configure(log4jConfProp);                log.error("Logger failed to load log4j.xml, defaulted to "                           + "log4j.properties: " + e);            }        }         else         {        	PropertyConfigurator.configure(log4jConfProp);            log.info("DSpace logging installed using log4j.properties");        }    }