org.LexGrid.util.config
Class Log4JUtility

java.lang.Object
  extended by org.LexGrid.util.config.Log4JUtility

public class Log4JUtility
extends java.lang.Object

Class to aid in configuring log4j

Author:
Dan Armbrust

Constructor Summary
Log4JUtility()
           
 
Method Summary
static void configureLog4j(java.util.Properties props)
          Configure log4j from a properties object.
static void configureLog4j(java.util.Properties props, java.lang.String baseLogOutputDirectory)
          Configure log4j from a properties object.
static void configureLog4j(java.lang.String log4JConfigFile)
          Configure log4j from a config file.
static void configureLog4j(java.lang.String log4JConfigFile, java.lang.String baseLogOutputDirectory)
          Method to read in a log4j config file, modify every property that ends with "File" such that the baseFilePath value is prefixed onto it, and then configure log4j with the results.
static void configureLog4JFromPathSpecifiedInProperties(java.util.Properties properties, java.lang.String log4JConfigFilePropertyName, boolean setLogOutputBaseDirToPropertiesPath)
          Configure log4j with the a config file specified by a value in a properties object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Log4JUtility

public Log4JUtility()
Method Detail

configureLog4JFromPathSpecifiedInProperties

public static void configureLog4JFromPathSpecifiedInProperties(java.util.Properties properties,
                                                               java.lang.String log4JConfigFilePropertyName,
                                                               boolean setLogOutputBaseDirToPropertiesPath)
                                                        throws java.lang.Exception
Configure log4j with the a config file specified by a value in a properties object. If the log4j file path specified in the properties object is a relative (or short) path, this method will prepend the value of 'propertiesFileParentFolder' to the path first. The method PropertiesUtility.loadPropertiesFromFileOrURL will assign the necessary information automatically. It is recommended that the Properties object that you pass into this class be created with the PropertiesUtility.loadPropertiesFromFileOrURL method.

Parameters:
properties - The properties object to look in for the file name of the log4j config file.
log4JConfigFilePropertyName - The property name in the properties object that has a corresponding value with the path of the log4j config file.
setLogOutputBaseDirToPropertiesPath - Should the log4j config file be modifed so that all appenders that end with "File" have the base directory of the location of the properties file prepended to them? If true - this also requires having the 'propertiesFileParentFolder' value set.
Throws:
java.lang.Exception

configureLog4j

public static void configureLog4j(java.lang.String log4JConfigFile,
                                  java.lang.String baseLogOutputDirectory)
                           throws java.io.IOException
Method to read in a log4j config file, modify every property that ends with "File" such that the baseFilePath value is prefixed onto it, and then configure log4j with the results. Useful for making log4j configuration work with relative file paths.

Parameters:
log4JConfigFile - The file (or URL) to read the log4j configuration from
baseFilePath - The path to prefix onto all values that end with "File" in the log4j config file.
Throws:
java.io.IOException

configureLog4j

public static void configureLog4j(java.lang.String log4JConfigFile)
                           throws java.io.IOException
Configure log4j from a config file.

Parameters:
log4JConfigFile - File (or URL) to use to configure log4j.
Throws:
java.io.IOException

configureLog4j

public static void configureLog4j(java.util.Properties props)
Configure log4j from a properties object.

Parameters:
props - The log4j properties

configureLog4j

public static void configureLog4j(java.util.Properties props,
                                  java.lang.String baseLogOutputDirectory)
Configure log4j from a properties object. Modifies every property that ends with "File" such that the baseFilePath value is prefixed onto it, and then configure log4j with the results. Useful for making log4j configuration work with relative file paths.

Parameters:
props - properties to load.
baseLogOutputDirectory - directory path to prefix onto items ending with "File"

Copyright: (c) 2004-2006 Mayo Foundation for Medical Education and Research (MFMER). All rights reserved. MAYO, MAYO CLINIC, and the triple-shield Mayo logo are trademarks and service marks of MFMER.