You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Bob Herrmann <bo...@jadn.com> on 2002/07/25 12:42:27 UTC

[logging] Redirecting System.out to JDK1.4 Logging for tomcat

I don't know if anyone else will find this interesting, but I wrote a
class which redirects System.Out to JDK1.4 Logging.  It is Tomcat 
aware and unrolls the stack in a way useful for Tomcat.  This might be
useful if you are embedding Tomcat.

I changed catalina.sh to start my class, it then invokes Bootstrap.

Any comments?

Cheers,
-bob






Re: [logging] Redirecting System.out to JDK1.4 Logging for tomcat

Posted by Janek Bogucki <ya...@studylink.com>.
> $ cd jakarta-tomcat-4.0
> $ grep -i 'log(' `find . -name *.java `|grep void|cut -f1
> -d:|sort|uniq|wc -l
>      65

Or

 $ cd jakarta-tomcat-4.0
 $ grep -i -l 'void.*log(' `find . -name *.java`|wc -l  

:)

Janek

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [logging] Redirecting System.out to JDK1.4 Logging for tomcat

Posted by Bob Herrmann <bo...@jadn.com>.
On Thu, 2002-07-25 at 07:13, Remy Maucherat wrote:
> Bob Herrmann wrote:
> > I don't know if anyone else will find this interesting, but I wrote a
> > class which redirects System.Out to JDK1.4 Logging.  It is Tomcat 
> > aware and unrolls the stack in a way useful for Tomcat.  This might be
> > useful if you are embedding Tomcat.
> > 
> > I changed catalina.sh to start my class, it then invokes Bootstrap.
> > 
> > Any comments?
> 
> AFAIK, Glenn used the Jasper sys.out redirector (and put it in 
> j-t-c/util) to do that. It doesn't redirect everything, but I believe it 
> redirects everything significant.
> 
> The advantages are:
> - It then redirects to one of the Catalina loggers
> - It doesn't depend on JDK 1.4

True.  My approach is tuned for 2 things,
 - utilizing JDK 1.4 logging 
 - unrolling the Tomcat stack in a way to get to "interesting bits of
stack"

You are right that this isn't something everyone would want.  If you are
trying to get Tomcat to log though JDK 1.4, then my approach might be
useful.  

The stack unrolling is helpful, IMHO, because it helps to identify which
class and method called the logger.  

I would like to have used commons-logging to get to JDK1.4's backend. 
Alas commons-logging doesn't support arbitrary stack unrolling
methods... And Tomcat has a lot of log wrappers....

$ cd jakarta-tomcat-4.0
$ grep -i 'log(' `find . -name *.java `|grep void|cut -f1
-d:|sort|uniq|wc -l
     65

To migrate to commons-logging, it looks like at least 65 classes need to
be adjusted.  I presume this will take awhile.  Using my approach is a
quick stop gap.   Perhaps Tomcat 5 will embrace the migration to
commons-logging.

Cheers,
-bob

Related Thread:
http://www.mail-archive.com/tomcat-dev@jakarta.apache.org/msg28257.html



> 
> Remy
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [logging] Redirecting System.out to JDK1.4 Logging for tomcat

Posted by Bob Herrmann <bo...@jadn.com>.
On Thu, 2002-07-25 at 07:13, Remy Maucherat wrote:
> Bob Herrmann wrote:
> > I don't know if anyone else will find this interesting, but I wrote a
> > class which redirects System.Out to JDK1.4 Logging.  It is Tomcat 
> > aware and unrolls the stack in a way useful for Tomcat.  This might be
> > useful if you are embedding Tomcat.
> > 
> > I changed catalina.sh to start my class, it then invokes Bootstrap.
> > 
> > Any comments?
> 
> AFAIK, Glenn used the Jasper sys.out redirector (and put it in 
> j-t-c/util) to do that. It doesn't redirect everything, but I believe it 
> redirects everything significant.
> 
> The advantages are:
> - It then redirects to one of the Catalina loggers
> - It doesn't depend on JDK 1.4

True.  My approach is tuned for 2 things,
 - utilizing JDK 1.4 logging 
 - unrolling the Tomcat stack in a way to get to "interesting bits of
stack"

You are right that this isn't something everyone would want.  If you are
trying to get Tomcat to log though JDK 1.4, then my approach might be
useful.  

The stack unrolling is helpful, IMHO, because it helps to identify which
class and method called the logger.  

I would like to have used commons-logging to get to JDK1.4's backend. 
Alas commons-logging doesn't support arbitrary stack unrolling
methods... And Tomcat has a lot of log wrappers....

$ cd jakarta-tomcat-4.0
$ grep -i 'log(' `find . -name *.java `|grep void|cut -f1
-d:|sort|uniq|wc -l
     65

To migrate to commons-logging, it looks like at least 65 classes need to
be adjusted.  I presume this will take awhile.  Using my approach is a
quick stop gap.   Perhaps Tomcat 5 will embrace the migration to
commons-logging.

Cheers,
-bob

Related Thread:
http://www.mail-archive.com/tomcat-dev@jakarta.apache.org/msg28257.html



> 
> Remy
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [logging] Redirecting System.out to JDK1.4 Logging for tomcat

Posted by Remy Maucherat <re...@apache.org>.
Bob Herrmann wrote:
> I don't know if anyone else will find this interesting, but I wrote a
> class which redirects System.Out to JDK1.4 Logging.  It is Tomcat 
> aware and unrolls the stack in a way useful for Tomcat.  This might be
> useful if you are embedding Tomcat.
> 
> I changed catalina.sh to start my class, it then invokes Bootstrap.
> 
> Any comments?

AFAIK, Glenn used the Jasper sys.out redirector (and put it in 
j-t-c/util) to do that. It doesn't redirect everything, but I believe it 
redirects everything significant.

The advantages are:
- It then redirects to one of the Catalina loggers
- It doesn't depend on JDK 1.4

Remy


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>