avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gautam Mani" <gm...@unwiredsoft.com>
Subject RE: LogKit problems
Date Tue, 26 Jun 2001 04:46:31 GMT
Hi,
Would it not make sense to put this into the tree; since
a lot of people use it?

Cheers,
Gautam

-- 
How can you have any pudding if you don't eat your meat?
		-- Pink Floyd



> -----Original Message-----
> From: Peter Donald [mailto:donaldp@apache.org]
> Sent: Tuesday, June 26, 2001 8:53 AM
> To: Avalon Development
> Subject: Re: LogKit problems
> 
> 
> On Tue, 26 Jun 2001 09:01, Mohit Dilawari wrote:
> > I am trying to use LogKit and I am having a bit of
> > trouble appending messages.
> >
> > I create a log file in a shell script and then I pass
> > the location of the logfile to a java program.  I
> > would like LogKit to append debug messages to this
> > file.
> >
> > Unfortunately, LogKit seems to delete the log file
> > before it writes to the logfile.
> >
> > How do I append trace messages to a file that is
> > already created from LogKit?
> >
> > The following is my code snippet:
> >
> > 	Logger logger =
> > Hierarchy.getDefaultHierarchy().getLoggerFor("myCategory");
> >
> > 	FileOutputLogTarget target = new
> > FileOutputLogTarget("C:\\SOD\\code\\test\\output\\out1.txt");
> > 			target.setFormat( "%7.7{priority} %5.5{time}
> > [%8.8{category}] " +
> >                   "(%{context}):
> > %{message}\\n%{throwable}" );
> >
> > 	logger.setLogTargets( new LogTarget[] { target } );
> >
> >
> > 	logger.setPriority( Priority.DEBUG );
> > 	logger.debug( "This is a debug message" );
> 
> Thats the desired behaviour ;) Probably the best thing you 
> could do would be 
> to add a new LogTarget such as
> 
> public class MyFileOutputLogTarget
>     extends DefaultOutputLogTarget
> {
>     public void setFilename( final String filename )
>         throws IOException
>     {
>         final File file = new File( filename );
>         final File parent = file.getAbsoluteFile().getParentFile();
>         if( !parent.exists() ) parent.mkdirs();
>         
>         //Next line is different and tells system to append
>         m_output = new FileWriter( filename, true );
>     }
> }
> 
> 
> Cheers,
> 
> Pete
> 
> *-----------------------------------------------------*
> | "Faced with the choice between changing one's mind, |
> | and proving that there is no need to do so - almost |
> | everyone gets busy on the proof."                   |
> |              - John Kenneth Galbraith               |
> *-----------------------------------------------------*
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: avalon-dev-help@jakarta.apache.org
> 
> 

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


Mime
View raw message