avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Berin Loritsch <blorit...@apache.org>
Subject Re: Asynchronous LogTarget
Date Wed, 16 Jan 2002 13:36:51 GMT
Peter Donald wrote:

> On Wed, 16 Jan 2002 15:57, Berin Loritsch wrote:
> 
>>Peter Donald wrote:
>>
>>>Are you using the CVS version of it?
>>>
>>Yes.
>>
> 
> you sure ?


I believe the problem *may* have to do with the factory class
in LogKitManager then.

BTW, shouldn't the thread that AsyncLogTarget be marked as a
daemon thread?  That would allow you to simply return from
the Main class, and not do a hard System.exit().


> 
> The following works for me
> 
> package org.apache.log.output;
> 
> import org.apache.log.Hierarchy;
> import org.apache.log.Logger;
> import org.apache.log.LogTarget;
> import org.apache.log.format.PatternFormatter;
> import org.apache.log.output.io.StreamTarget;
> 
> public class AsyncLogTest
> {
> 
>     public static void main( String[] args )
>     {
>         final PatternFormatter formatter = new PatternFormatter( 
> "%{message}\n" );
>         final LogTarget mySlowTarget = new StreamTarget( System.out, 
> formatter );
>         AsyncLogTarget asyncTarget = new AsyncLogTarget( mySlowTarget );
>         Thread thread = new Thread( asyncTarget );
>         thread.setPriority( Thread.MIN_PRIORITY );
>         thread.start();
> 
>         final Hierarchy h = new Hierarchy();
>         final Logger logger = h.getLoggerFor( "meep" );
>         logger.setLogTargets( new LogTarget[] { asyncTarget } );
> 
>         logger.debug( "meep meep!" );
>         logger.debug( "meep meep!" );
>         logger.debug( "meep meep!" );
>     }
> }
> 
> 
> 
> 



-- 

"They that give up essential liberty to obtain a little temporary safety
  deserve neither liberty nor safety."
                 - Benjamin Franklin


--
To unsubscribe, e-mail:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>


Mime
View raw message