niclas 2004/02/24 16:37:41
Modified: logging/log4j/src/java/org/apache/avalon/logging/log4j
Log4JLoggingFactory.java
logging/log4j/test/conf logging.xml
logging/log4j/test/src/test/org/apache/avalon/logging/log4j/test
DefaultLoggingManagerTestCase.java
logging/site/xdocs/impl/log4j index.xml
Log:
Fixed up some remaining issues.
Revision Changes Path
1.2 +50 -24
avalon/logging/log4j/src/java/org/apache/avalon/logging/log4j/Log4JLoggingFactory.java
Index: Log4JLoggingFactory.java
===================================================================
RCS file:
/home/cvs/avalon/logging/log4j/src/java/org/apache/avalon/logging/log4j/Log4JLoggingFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Log4JLoggingFactory.java 24 Feb 2004 21:37:37 -0000 1.1
+++ Log4JLoggingFactory.java 25 Feb 2004 00:37:41 -0000 1.2
@@ -18,6 +18,11 @@
package org.apache.avalon.logging.log4j;
+import java.io.File;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
import java.util.HashMap;
import java.util.Map;
@@ -48,7 +53,7 @@
private final ClassLoader m_Classloader;
private final InitialContext m_Context;
- private boolean m_Log4JInitialized;
+ private File m_BaseDirectory;
/**
* Creation of a new default factory.
@@ -59,7 +64,6 @@
{
m_Context = context;
m_Classloader = classloader;
- m_Log4JInitialized = false;
}
/**
@@ -88,28 +92,28 @@
public Object create( Map criteriaMap )
throws Exception
{
- if( ! m_Log4JInitialized )
+ if( null == criteriaMap )
+ {
+ throw new NullPointerException( "criteriaMap" );
+ }
+
+ final LoggingCriteria criteria = getLoggingCriteria( criteriaMap );
+ m_BaseDirectory = criteria.getBaseDirectory();
+
+ final Configuration config = criteria.getConfiguration();
+ Configuration srcConf = config.getChild( "src" );
+ Configuration updateConf = config.getChild( "update" );
+ String src = srcConf.getValue();
+ src = resolveSource( src );
+ System.out.println( src );
+ long updateInterval = updateConf.getValueAsLong( 0 );
+ if( updateInterval > 0 )
+ {
+ configureWithWatch( src, updateInterval );
+ }
+ else
{
- if( null == criteriaMap )
- {
- throw new NullPointerException( "criteriaMap" );
- }
-
- final LoggingCriteria criteria = getLoggingCriteria( criteriaMap );
-
- final Configuration config = criteria.getConfiguration();
- Configuration srcConf = config.getChild( "src" );
- Configuration updateConf = config.getChild( "update" );
- String src = srcConf.getValue();
- long updateInterval = updateConf.getValueAsLong( 0 );
- if( updateInterval > 0 )
- {
- configureWithWatch( src, updateInterval );
- }
- else
- {
- configureWithOutWatch( src );
- }
+ configureWithOutWatch( src );
}
return new LoggingManagerImpl();
}
@@ -138,6 +142,28 @@
}
}
+ private String resolveSource( String src )
+ {
+ try
+ {
+ URL url = new URL( src );
+ if( url.getProtocol().equals( "file" ) )
+ return resolveToBaseDir( src );
+ return src;
+ } catch( MalformedURLException e )
+ {
+ return resolveToBaseDir( src );
+ }
+ }
+
+ private String resolveToBaseDir( String src )
+ {
+ if( src.startsWith( "/" ) )
+ return src;
+ File f = new File( m_BaseDirectory, src );
+ return f.getAbsolutePath();
+ }
+
private LoggingCriteria getLoggingCriteria( Map map )
{
if( map instanceof LoggingCriteria )
1.2 +1 -1 avalon/logging/log4j/test/conf/logging.xml
Index: logging.xml
===================================================================
RCS file: /home/cvs/avalon/logging/log4j/test/conf/logging.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- logging.xml 24 Feb 2004 21:37:38 -0000 1.1
+++ logging.xml 25 Feb 2004 00:37:41 -0000 1.2
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<logging>
- <src>conf/log4j.xml</src>
+ <src>../conf/log4j.xml</src>
<update>1000</update>
</logging>
1.3 +7 -7
avalon/logging/log4j/test/src/test/org/apache/avalon/logging/log4j/test/DefaultLoggingManagerTestCase.java
Index: DefaultLoggingManagerTestCase.java
===================================================================
RCS file:
/home/cvs/avalon/logging/log4j/test/src/test/org/apache/avalon/logging/log4j/test/DefaultLoggingManagerTestCase.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultLoggingManagerTestCase.java 24 Feb 2004 21:55:38 -0000 1.2
+++ DefaultLoggingManagerTestCase.java 25 Feb 2004 00:37:41 -0000 1.3
@@ -102,10 +102,10 @@
logger.error(
"this is an error message from test",
new LoggingException(
- "woops",
+ "Intentional Exception for TestCase.",
new LoggingException(
- "my fault",
- new LoggingException( "bad attitude" ) ) ) );
+ "nested level 1",
+ new LoggingException( "nested level 2" ) ) ) );
logger.fatalError( "this is a fatal message from test" );
}
@@ -119,10 +119,10 @@
logger.error(
"this is an error message from roger ramjet",
new LoggingException(
- "woops",
+ "Intentional Exception for TestCase.",
new LoggingException(
- "my fault",
- new LoggingException( "bad attitude" ) ) ) );
+ "nested level 1",
+ new LoggingException( "nested level 2" ) ) ) );
logger.fatalError( "this is a fatal message from roger ramjet" );
}
1.2 +4 -2 avalon/logging/site/xdocs/impl/log4j/index.xml
Index: index.xml
===================================================================
RCS file: /home/cvs/avalon/logging/site/xdocs/impl/log4j/index.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- index.xml 25 Feb 2004 00:01:30 -0000 1.1
+++ index.xml 25 Feb 2004 00:37:41 -0000 1.2
@@ -40,7 +40,8 @@
</p>
<p>
<strong>NOTE! </strong> "Base Directory"
- (property "avalon.logging.basedir") is NOT SUPPORTED, and
+ (property "avalon.logging.basedir") is NOT SUPPORTED
+ inside any Log4J configuration files, and
all relative filenames inside the Log4J configuration will
relative to <strong>user.dir</strong> (current directory).
</p>
@@ -54,7 +55,8 @@
The filename or URL of the Log4J configuration file. This
file can either be an XML or a Properties configuration file,
but MUST end with <strong>".xml"</strong> if it is
- the former.
+ the former. A relative filename will resolve relative to
+ <strong>Base Directory</strong> (property
"avalon.logging.basedir").
</td>
</tr>
<tr>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]