Debugging JSPs and Servlets

2002-02-27 Thread Nitin Vira

Hello,

I am trying to create an environment that will assist in debugging jsps, i think one 
of the basic ways to do debugging is through logging, I want to log various request 
coming in along with the request parameters, i checked the access loggs but they only 
logg GET request also it doesnt logg the parameters, is there anyway i can logg POST 
request too along with the request parameters, i can possibly use a filter to do it, 
will that be a right approach also can i configure a filter to run for all the 
servlets? Also is it possible to logg something like forwards to another page and 
including other pages, also if you have any other suggestions to add features that 
will assist in debugging that i can implement i will greatly appreciate it.

Thanks,
Nitin

--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




RE: Debugging JSPs and Servlets

2002-02-27 Thread Wagoner, Mark

Take a look at Log4j http://jakarta.apache.org/log4j/docs/index.html

It has been the greatest debugging tool I have found.

-Original Message-
From: Nitin Vira [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 27, 2002 12:47 PM
To: Tomcat Users List
Subject: Debugging JSPs and Servlets


Hello,

I am trying to create an environment that will assist in debugging jsps, i
think one of the basic ways to do debugging is through logging, I want to
log various request coming in along with the request parameters, i checked
the access loggs but they only logg GET request also it doesnt logg the
parameters, is there anyway i can logg POST request too along with the
request parameters, i can possibly use a filter to do it, will that be a
right approach also can i configure a filter to run for all the servlets?
Also is it possible to logg something like forwards to another page and
including other pages, also if you have any other suggestions to add
features that will assist in debugging that i can implement i will greatly
appreciate it.

Thanks,
Nitin

--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]

--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Re: Debugging JSPs and Servlets

2002-02-27 Thread Sriram Narayanan

2/27/02 11:17:26 PM, Nitin Vira [EMAIL PROTECTED] wrote:

Hello,

I am trying to create an environment that will assist in debugging jsps, i think one 
of the basic ways to do debugging is through logging, I want 
to log various request coming in along with the request parameters, i checked the 
access loggs but they only logg GET request also it doesnt 
logg the parameters, is there anyway i can logg POST request too along with the 
request parameters, i can possibly use a filter to do it, will that 
be a right approach also can i configure a filter to run for all the servlets? Also is 
it possible to logg something like forwards to another page and 
including other pages, also if you have any other suggestions to add features that 
will assist in debugging that i can implement i will greatly 
appreciate it.


Use Log4J. (http://jakarta.apache.org/log4j) 

Log4J has something called Logging Levels, e.g. DEBUG, ERROR, INFO etc...

Let's say you have some 15 packages with some 10 classes in each.

In each class, instantiate a Logger with the statement

static Logger logger = Logger.getInstance(MyClass.class.getName());

Now within the class, write both DEBUG level statements and INFO level statements:

e.g. 

public void someTask(String first, String second){
logger.debug(just entered the someTask method, args are  + first + : + 
second);
logger.info(about to calculate something);
int x = calculate();
logger.debug(the calculation result was  + x);
}

Now, DEBUG levels happen to be lower in importance than INFO levels. 

Log4J can be instructed on which level to log via a properties file.
So, you can change log levels, or even disable loggin altogether via an external 
properties file. No changes to the code are required at all.

Also, you can specify that the log outputs from a particular class should be 
redirected to one file, while all other logs could go to another file, or 
even a JDBC target.


Thanks,
Nitin


Sriram


_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Re: Debugging JSPs and Servlets

2002-02-27 Thread Craig R. McClanahan



On Wed, 27 Feb 2002, Nitin Vira wrote:

 Date: Wed, 27 Feb 2002 09:47:26 -0800
 From: Nitin Vira [EMAIL PROTECTED]
 Reply-To: Tomcat Users List [EMAIL PROTECTED]
 To: Tomcat Users List [EMAIL PROTECTED]
 Subject: Debugging JSPs and Servlets

 Hello,

 I am trying to create an environment that will assist in debugging jsps,
 i think one of the basic ways to do debugging is through logging, I want
 to log various request coming in along with the request parameters, i
 checked the access loggs but they only logg GET request also it doesnt
 logg the parameters, is there anyway i can logg POST request too along
 with the request parameters, i can possibly use a filter to do it, will
 that be a right approach also can i configure a filter to run for all
 the servlets? Also is it possible to logg something like forwards to
 another page and including other pages, also if you have any other
 suggestions to add features that will assist in debugging that i can
 implement i will greatly appreciate it.

 Thanks,
 Nitin

 --
 To unsubscribe:   mailto:[EMAIL PROTECTED]
 For additional commands: mailto:[EMAIL PROTECTED]
 Troubles with the list: mailto:[EMAIL PROTECTED]

Logging stuff for yourself is a nice use case for a Filter.  In fact,
there's an example filter that does this kind of thing in the examples
webapp included with Tomcat 4.  Source code is in file
/WEB-INF/classes/filters/RequestDumperFilter.java.  You can see how it's
configured by looking at the web.xml file for this app.

Craig



--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Re: Debugging JSPs and Servlets

2002-02-27 Thread August Detlefsen

For the quick and dirty approach, you can put System.out.println()
statements in your code and find the output in:

TOMCAT_HOME/logs/catalina.out



--- Sriram Narayanan [EMAIL PROTECTED] wrote:
 2/27/02 11:17:26 PM, Nitin Vira [EMAIL PROTECTED] wrote:
 
 Hello,
 
 I am trying to create an environment that will assist in debugging
 jsps, i think one of the basic ways to do debugging is through
 logging, I want 
 to log various request coming in along with the request parameters, i
 checked the access loggs but they only logg GET request also it
 doesnt 
 logg the parameters, is there anyway i can logg POST request too
 along with the request parameters, i can possibly use a filter to do
 it, will that 
 be a right approach also can i configure a filter to run for all the
 servlets? Also is it possible to logg something like forwards to
 another page and 
 including other pages, also if you have any other suggestions to add
 features that will assist in debugging that i can implement i will
 greatly 
 appreciate it.
 
 
 Use Log4J. (http://jakarta.apache.org/log4j) 
 
 Log4J has something called Logging Levels, e.g. DEBUG, ERROR, INFO
 etc...
 
 Let's say you have some 15 packages with some 10 classes in each.
 
 In each class, instantiate a Logger with the statement
 
 static Logger logger = Logger.getInstance(MyClass.class.getName());
 
 Now within the class, write both DEBUG level statements and INFO
 level statements:
 
 e.g. 
 
 public void someTask(String first, String second){
   logger.debug(just entered the someTask method, args are  + first +
 : + second);
   logger.info(about to calculate something);
   int x = calculate();
   logger.debug(the calculation result was  + x);
 }
 
 Now, DEBUG levels happen to be lower in importance than INFO levels. 
 
 Log4J can be instructed on which level to log via a properties file.
 So, you can change log levels, or even disable loggin altogether via
 an external properties file. No changes to the code are required at
 all.
 
 Also, you can specify that the log outputs from a particular class
 should be redirected to one file, while all other logs could go to
 another file, or 
 even a JDBC target.
 
 
 Thanks,
 Nitin
 
 
 Sriram
 
 
 _
 Do You Yahoo!?
 Get your free @yahoo.com address at http://mail.yahoo.com
 
 
 --
 To unsubscribe:   mailto:[EMAIL PROTECTED]
 For additional commands: mailto:[EMAIL PROTECTED]
 Troubles with the list: mailto:[EMAIL PROTECTED]
 


__
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com

--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]