geirm 01/08/20 04:44:49
Modified: src/java/org/apache/velocity/runtime/log
AvalonLogSystem.java LogSystem.java
Log:
Added idea/patch from Carsten Ziegeler <[EMAIL PROTECTED]> to allow
user to just specify an existing AvalonLogger by name.
Also, the LogSystem.init() method throws an exception - if it can't get
logging going, it has to do something (since it can't tell you via the
logs...). Also modified AvalonLogSystem to throw an Exception if it
can't get started.
Revision Changes Path
1.9 +35 -19
jakarta-velocity/src/java/org/apache/velocity/runtime/log/AvalonLogSystem.java
Index: AvalonLogSystem.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/log/AvalonLogSystem.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- AvalonLogSystem.java 2001/08/20 11:09:21 1.8
+++ AvalonLogSystem.java 2001/08/20 11:44:49 1.9
@@ -74,7 +74,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jon S. Stevens</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: AvalonLogSystem.java,v 1.8 2001/08/20 11:09:21 geirm Exp $
+ * @version $Id: AvalonLogSystem.java,v 1.9 2001/08/20 11:44:49 geirm Exp $
*/
public class AvalonLogSystem implements LogSystem
{
@@ -93,31 +93,47 @@
}
public void init( RuntimeServices rs )
+ throws Exception
{
this.rsvc = rs;
/*
- * since this is a Velocity-provided logger, we will
- * use the Runtime configuration
+ * if a logger is specified, we will use this instead of
+ * the default
*/
- String logfile = (String) rsvc.getProperty( RuntimeConstants.RUNTIME_LOG );
-
- /*
- * now init. If we can't, panic!
- */
- try
+ String loggerName = (String)
rsvc.getProperty("runtime.log.logsystem.avalon.logger");
+
+ if (loggerName != null)
{
- init( logfile );
-
- logVelocityMessage( 0,
- "AvalonLogSystem initialized using logfile " + logPath );
- }
- catch( Exception e )
+ this.logger = Hierarchy.getDefaultHierarchy().getLoggerFor(loggerName);
+ }
+ else
{
- System.out.println(
- "PANIC : Error configuring AvalonLogSystem : " + e );
- System.err.println(
- "PANIC : Error configuring AvalonLogSystem : " + e );
+ /*
+ * since this is a Velocity-provided logger, we will
+ * use the Runtime configuration
+ */
+ String logfile = (String) rsvc.getProperty(
RuntimeConstants.RUNTIME_LOG );
+
+ /*
+ * now init. If we can't, panic!
+ */
+ try
+ {
+ init( logfile );
+
+ logVelocityMessage( 0,
+ "AvalonLogSystem initialized using logfile " + logPath );
+ }
+ catch( Exception e )
+ {
+ System.out.println(
+ "PANIC : Error configuring AvalonLogSystem : " + e );
+ System.err.println(
+ "PANIC : Error configuring AvalonLogSystem : " + e );
+
+ throw new Exception("Unable to configure AvalonLogSystem : " + e );
+ }
}
}
1.7 +2 -2
jakarta-velocity/src/java/org/apache/velocity/runtime/log/LogSystem.java
Index: LogSystem.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/log/LogSystem.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- LogSystem.java 2001/08/07 22:07:37 1.6
+++ LogSystem.java 2001/08/20 11:44:49 1.7
@@ -61,7 +61,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jon S. Stevens</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: LogSystem.java,v 1.6 2001/08/07 22:07:37 geirm Exp $
+ * @version $Id: LogSystem.java,v 1.7 2001/08/20 11:44:49 geirm Exp $
*/
public interface LogSystem
{
@@ -90,7 +90,7 @@
/**
* init()
*/
- public void init( RuntimeServices rs );
+ public void init( RuntimeServices rs ) throws Exception;
/**
* Send a log message from Velocity.