tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luc Foisy" <Luc.Fo...@technical-magic.com>
Subject RE: How do I...
Date Fri, 10 Jan 2003 21:03:25 GMT

> On Friday 10 January 2003 02:24 pm, Luc Foisy wrote:
> > Thanks paul, that was some kind of answer I was looking for.
> >
> > Since the documentation said this (after looking at it 
> again just moments
> > ago) Standard Error Logger 
> (org.apache.catalina.logger.SystemErrLogger) The
> > Standard Error Logger records all logged messages to 
> whatever stream the
> > standard error output of Catalina is pointed at. The 
> default Catalina
> > startup script points this at file logs/catalina.out relative to
> > $CATALINA_HOME. This logger supports no additional attributes.
> >
> > Standard Output Logger (org.apache.catalina.logger.SystemOutLogger)
> > The Standard Output Logger records all logged messages to 
> whatever stream
> > the standard output of Catalina is pointed at. The default 
> Catalina startup
> > script points this at file logs/catalina.out relative to 
> $CATALINA_HOME.
> > This logger supports no additional attributes.
> >
> > So I was guessing that context specific stuff couldnt be managed for
> > System.out
> >
> > At the moment we have a jar file application (non web) so 
> in development
> > mode we have stuff going through System.out When we deploy 
> to the web,
> > there are a few extra classes to bridge the application 
> with the web side
> > of things.
> >
> > So in my jsp's we can simply call this 
> ServletContext.log(), what would be
> > the best way to snafu all the System.out and push it through
> > ServletContext.log()??
> >
> > And here is my nomination for Context specific System.out 
> logging done by
> > tomcat! :)
> 
> o.a.c.logger.SystemOutLogger and o.a.c.logger.SystemErrLogger 
> do the opposite 
> of what you want. They direct all ServletContext.log() for a 
> specific Context 
> to the Catalina's standard output or standard error output 
> respectively.
> 
> Like I said I believe you can't cheat System.out.print() into 
> working like 
> ServletContext.log(), which gives you the convinience of 
> per-Context Loggers. 
> You can only change the entire Tomcat engine's standard 
> (error) output to a 
> destination other than $CATALINA_HOME/logs/catalina.out as 
> laid out in my 
> previous message.
> 
> You may have to write a Perl script or use sed (or a Windows 
> equivalent, if 
> any) to replace every occurance of 
> System.out.print()/println() with calls to 
> a good logging API like commons-logging or log4j.
> 

Could I pass the ServletContext to my jar application, and reroute System.out in there with
System static void setOut(PrintStream out) ?
Do you see any issues with that?

I briefly looked at the Tomcat source to see what it was doing Catalina.java is just routing
all System.out to SystemLogHandler.java ( which is a PrintStream )
Not quite sure at the moment where the Contexts come into play ( not sure where they are linked
to that same SystemLogHandler )
Where does the context logger parameter from server.xml get loaded in?

What do you think Tomcat would do if I snafu'd my System.out?
 

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


Mime
View raw message