/*
Logging In Java with the JDK 1.4 Logging API and Apache log4j
by Samudra Gupta
Apress Copyright 2003
ISBN:1590590996
*/
//
/*
If this property is not passed to the logging framework at startup,
by default, LogManager reads a configuration file located in the
"JAVA_HOME/jre/lib/ logging.properties" file. This configuration
file defines the default configuration parameters for the logging
framework to work. It is possible to override the default location
and specify our own configuration file by passing a command line
option to the Java runtime as:
java -Djava.util.logging.config.file=configuration file name
RemoteConfigReader.java
*/
import java.util.logging.LogManager;
import java.net.URL;
import java.net.URLConnection;
import java.net.MalformedURLException;
import java.io.InputStream;
import java.io.IOException;
publicclass RemoteConfigReader
{
private String urlString = "http://www.xyz.com/config.properties";
private URL url = null;
private URLConnection urlConn = null;
private InputStream inStream = null;
private LogManager manager = null;
/**
* The constructor obtains a connection to the URL specified in the
* urlString object, obtains an InputStream on the URL and
* calls the readConfiguration(InputStream) of the LogManager class
* to perform the initialization
*/
public RemoteConfigReader(){
try{
url = new URL(urlString);
urlConn = url.openConnection();
inStream = urlConn.getInputStream();
manager = LogManager.getLogManager();
manager.readConfiguration(inStream);
}catch(MalformedURLException mue){
System.out.println("could not open url: "+urlString);
}catch(IOException ioe){
System.out.println("IOException occured in reading: "+urlString);
}catch(SecurityException se){
System.out.println("Security exception occured in class RemoteConfigLoader");
}
}
}