You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by sn...@apache.org on 2007/07/27 16:12:02 UTC
svn commit: r560240 - in
/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger:
config/WebloggerConfig.java config/roller.properties
ui/core/RollerContext.java
Author: snoopdave
Date: Fri Jul 27 07:11:56 2007
New Revision: 560240
URL: http://svn.apache.org/viewvc?view=rev&rev=560240
Log:
Better fix for ROL-1491, now init logging in WebloggerConfig. Seems to work well and typically only one message will hit System.out before logging gets configured.
Modified:
roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/config/WebloggerConfig.java
roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/config/roller.properties
roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/RollerContext.java
Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/config/WebloggerConfig.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/config/WebloggerConfig.java?view=diff&rev=560240&r1=560239&r2=560240
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/config/WebloggerConfig.java (original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/config/WebloggerConfig.java Fri Jul 27 07:11:56 2007
@@ -22,10 +22,10 @@
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Enumeration;
-import java.util.Iterator;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.PropertyConfigurator;
import org.apache.roller.util.PropertyExpander;
@@ -39,18 +39,18 @@
private static String custom_jvm_param = "roller.custom.config";
private static File custom_config_file = null;
- private static Properties mConfig;
+ private static Properties config;
private static Log log = LogFactory.getLog(WebloggerConfig.class);
-
+
/*
* Static block run once at class loading
*
* We load the default properties and any custom properties we find
*/
static {
- mConfig = new Properties();
+ config = new Properties();
try {
// we'll need this to get at our properties files in the classpath
@@ -58,16 +58,15 @@
// first, lets load our default properties
InputStream is = config_class.getResourceAsStream(default_config);
- mConfig.load(is);
- log.info("successfully loaded default properties.");
+ config.load(is);
// now, see if we can find our custom config
is = config_class.getResourceAsStream(custom_config);
if(is != null) {
- mConfig.load(is);
- log.info("successfully loaded custom properties file from classpath");
+ config.load(is);
+ System.out.println("Roller Weblogger: Successfully loaded custom properties file from classpath");
} else {
- log.info("no custom properties file found in classpath");
+ System.out.println("Roller Weblogger: No custom properties file found in classpath");
}
// finally, check for an external config file
@@ -78,46 +77,46 @@
// make sure the file exists, then try and load it
if(custom_config_file != null && custom_config_file.exists()) {
is = new FileInputStream(custom_config_file);
- mConfig.load(is);
- log.info("successfully loaded custom properties from "+
+ config.load(is);
+ System.out.println("Roller Weblogger: Successfully loaded custom properties from "+
custom_config_file.getAbsolutePath());
} else {
- log.warn("failed to load custom properties from "+
+ System.out.println("Roller Weblogger: Failed to load custom properties from "+
custom_config_file.getAbsolutePath());
}
- } else {
- log.info("no custom properties file specified via jvm option");
- }
+ }
// Now expand system properties for properties in the config.expandedProperties list,
// replacing them by their expanded values.
- String expandedPropertiesDef = (String) mConfig.get("config.expandedProperties");
+ String expandedPropertiesDef = (String) config.get("config.expandedProperties");
if (expandedPropertiesDef != null) {
String[] expandedProperties = expandedPropertiesDef.split(",");
for (int i = 0; i < expandedProperties.length; i++) {
String propName = expandedProperties[i].trim();
- String initialValue = (String) mConfig.get(propName);
+ String initialValue = (String) config.get(propName);
if (initialValue != null) {
String expandedValue = PropertyExpander.expandSystemProperties(initialValue);
- mConfig.put(propName,expandedValue);
- if (log.isDebugEnabled()) {
- log.info("Expanded value of " + propName + " from '" +
- initialValue + "' to '" + expandedValue + "'");
- }
+ config.put(propName,expandedValue);
}
}
}
+
+ // initialize logging subsystem via WebloggerConfig
+ Properties log4jprops = new Properties();
+ PropertyConfigurator.configure(WebloggerConfig.getPropertiesStartingWith("log4j."));
+
+ // finally we can start logging...
// some debugging for those that want it
if(log.isDebugEnabled()) {
log.debug("WebloggerConfig looks like this ...");
String key = null;
- Enumeration keys = mConfig.keys();
+ Enumeration keys = config.keys();
while(keys.hasMoreElements()) {
key = (String) keys.nextElement();
- log.debug(key+"="+mConfig.getProperty(key));
+ log.debug(key+"="+config.getProperty(key));
}
}
@@ -138,8 +137,8 @@
* @return String Value of property requested, null if not found
*/
public static String getProperty(String key) {
- log.debug("Fetching property ["+key+"="+mConfig.getProperty(key)+"]");
- return mConfig.getProperty(key);
+ log.debug("Fetching property ["+key+"="+config.getProperty(key)+"]");
+ return config.getProperty(key);
}
/**
@@ -149,8 +148,8 @@
* @return String Value of property requested or defaultValue
*/
public static String getProperty(String key, String defaultValue) {
- log.debug("Fetching property ["+key+"="+mConfig.getProperty(key)+",defaultValue="+defaultValue+"]");
- String value = mConfig.getProperty(key);
+ log.debug("Fetching property ["+key+"="+config.getProperty(key)+",defaultValue="+defaultValue+"]");
+ String value = config.getProperty(key);
if(value == null)
return defaultValue;
@@ -202,7 +201,7 @@
* @return Enumeration A list of all keys
**/
public static Enumeration keys() {
- return mConfig.keys();
+ return config.keys();
}
@@ -211,9 +210,9 @@
*/
public static Properties getPropertiesStartingWith(String startingWith) {
Properties props = new Properties();
- for (Enumeration it = mConfig.keys(); it.hasMoreElements();) {
+ for (Enumeration it = config.keys(); it.hasMoreElements();) {
String key = (String)it.nextElement();
- props.put(key, mConfig.get(key));
+ props.put(key, config.get(key));
}
return props;
}
@@ -230,8 +229,8 @@
*/
public static void setUploadsDir(String path) {
// only do this if the user wants to use the webapp context
- if("${webapp.context}".equals(mConfig.getProperty("uploads.dir")))
- mConfig.setProperty("uploads.dir", path);
+ if("${webapp.context}".equals(config.getProperty("uploads.dir")))
+ config.setProperty("uploads.dir", path);
}
/**
@@ -245,8 +244,8 @@
*/
public static void setThemesDir(String path) {
// only do this if the user wants to use the webapp context
- if("${webapp.context}".equals(mConfig.getProperty("themes.dir")))
- mConfig.setProperty("themes.dir", path);
+ if("${webapp.context}".equals(config.getProperty("themes.dir")))
+ config.setProperty("themes.dir", path);
}
}
Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/config/roller.properties
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/config/roller.properties?view=diff&rev=560240&r1=560239&r2=560240
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/config/roller.properties (original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/config/roller.properties Fri Jul 27 07:11:56 2007
@@ -614,6 +614,20 @@
log4j.category.com.opensymphony.oscache=ERROR
log4j.category.com.danga.MemCached=WARN
+# Ask OpenJPA to log to Log4J via Apache Commons Logging
+openjpa.Log=commons
+
+log4j.category.openjpa.Tool=INFO
+log4j.category.openjpa.Runtime=INFO
+log4j.category.openjpa.Remote=WARN
+log4j.category.openjpa.DataCache=WARN
+log4j.category.openjpa.MetaData=WARN
+log4j.category.openjpa.Enhance=WARN
+log4j.category.openjpa.Query=WARN
+log4j.category.openjpa.jdbc.SQL=WARN
+log4j.category.openjpa.jdbc.JDBC=WARN
+log4j.category.openjpa.jdbc.Schema=WARN
+
#-----------------------------------------------------------------------------
# Other settings
Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/RollerContext.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/RollerContext.java?view=diff&rev=560240&r1=560239&r2=560240
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/RollerContext.java (original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/RollerContext.java Fri Jul 27 07:11:56 2007
@@ -105,10 +105,6 @@
// listeners don't initialize in the order specified in 2.3 containers
super.contextInitialized(sce);
- // Initialize logging subsystem via WebloggerConfig
- Properties log4jprops = new Properties();
- PropertyConfigurator.configure(WebloggerConfig.getPropertiesStartingWith("log4j."));
-
// get the *real* path to <context>/resources
String ctxPath = servletContext.getRealPath("/");
if(!ctxPath.endsWith(File.separator))