I have been investigating a problem where LogTargets wrapped in a
PriorityFilteringTarget were not being closed correctly on application
shutdown.

As it turns out, the cause is in the Excalibur Logger
PriorityFilterTargetFactory.

The logkit PriorityFilteringTarget class has a second constructor which
accepts
a closeWrappedTarget argument. The PriorityFilterTargetFactory is calling
a version of the constructor which defaults to setting that argument to
false.

There are no javadocs explaining the purpose of this argument in the
class, and
I am not sure of the timing of its addition. I am trying to decide where
and how
to fix this problem. I can not think of any reason why you would not want to
close down the wrapped log targets in the first place. But given that
someone
went out of their way to provide this behavior, it seems like closing
them by
default would be better behavior.

If I change the default, then I can do so in the LogKit project and be
done with it.

If however, there is a good reason not to close the wrapped targets down
then
I will need to add a configuration property to the Excalibur logger
PriorityFilterTargetFactory class as It should use the same defaults.

The thing is that if the LogTarget is not wrapped, it will always be closed
down. The case where it is Wrapped by a PriorityFilteringTarget is actually
the only case where it would not be closed.

For now, I am going to modify LogKit so the default is to close the wrapped
LogTargets when the PriorityFilteringTarget is closed. If there are any
concerns about this change then I can go back and change it. I only make
an issue of this because someone appears to have gone out of their way to
make it work this way...

Digging around in CVS, the class was recently created to replace the
deprecated
PriorityFilter. The old system worked differently, so from what I can
tell, this
was not an issue.

Ahh. As I went to commit this, I found that my karma has been revoked
for the
avalon-logkit project. :-( I work on Logkit from time to time so unless
there
was a reason for it, I would still like to have access. :-)

Here is the patch. If someone could commit it I would appreciate it.
In addition to the one line change, there are a few tabs to spaces fixes.

Cheers,
Leif
cvs diff -u PriorityFilteringTarget.java 
Index: PriorityFilteringTarget.java
===================================================================
RCS file: 
/home/cvs/avalon-logkit/src/java/org/apache/log/output/PriorityFilteringTarget.java,v
retrieving revision 1.3
diff -u -r1.3 PriorityFilteringTarget.java
--- PriorityFilteringTarget.java        28 Mar 2004 05:05:43 -0000      1.3
+++ PriorityFilteringTarget.java        30 Jul 2004 05:16:57 -0000
@@ -55,7 +55,7 @@
      */
     public PriorityFilteringTarget(Priority priority)
     {
-        this(priority, false );
+        this(priority, true );
     }
 
     /**
@@ -80,11 +80,11 @@
 
 
     /* (non-Javadoc)
-        * @see 
org.apache.log.output.AbstractTarget#doProcessEvent(org.apache.log.LogEvent)
-        */
-       protected void doProcessEvent(LogEvent event) throws Exception 
+     * @see 
org.apache.log.output.AbstractTarget#doProcessEvent(org.apache.log.LogEvent)
+     */
+    protected void doProcessEvent(LogEvent event) throws Exception 
     {
-               if ( event != null 
+        if ( event != null 
              && m_targets != null
              && !event.getPriority().isLower(m_priority) )
         {
@@ -93,7 +93,7 @@
                 m_targets[ i ].processEvent( event );
             }
         }              
-       }
+    }
     
     /* (non-Javadoc)
      * @see org.apache.log.util.Closeable#close()
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to