Re: Logging all data sent to client

2007-07-25 Thread ben short

One other note: since you were using a compression filter as an example,
I can see why they didn't do the whole "writer" thing. A compressed
stream cannot use a Writer since the output must be binary. A writer
primarily handles line-ending conversion which would break any
compression output generated.


Ah I hadnt thought of that :)

Yep it works ands not ment for production as the logging will have a
massive overhead.

On 7/25/07, Christopher Schultz <[EMAIL PROTECTED]> wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Ben,

ben short wrote:
> I ripped and altered the code of the Compression Filter servlet
> example from tomcat 5.5.23.

One other note: since you were using a compression filter as an example,
I can see why they didn't do the whole "writer" thing. A compressed
stream cannot use a Writer since the output must be binary. A writer
primarily handles line-ending conversion which would break any
compression output generated.

Since you are not bound by the requirement that an OutputStream be used,
I would recommend handling the Writer separately. But, hey, if it works,
it works, right?

- -chris

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGp7L/9CaO5/Lv0PARAsWZAJ42RaxekZB/uH8iCHoJu0aPclnpwgCeLHXl
/DG3WHjOB4Z8Kb1AXifKLqE=
=VpkL
-END PGP SIGNATURE-

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Logging all data sent to client

2007-07-25 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Ben,

ben short wrote:
> I ripped and altered the code of the Compression Filter servlet
> example from tomcat 5.5.23.

One other note: since you were using a compression filter as an example,
I can see why they didn't do the whole "writer" thing. A compressed
stream cannot use a Writer since the output must be binary. A writer
primarily handles line-ending conversion which would break any
compression output generated.

Since you are not bound by the requirement that an OutputStream be used,
I would recommend handling the Writer separately. But, hey, if it works,
it works, right?

- -chris

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGp7L/9CaO5/Lv0PARAsWZAJ42RaxekZB/uH8iCHoJu0aPclnpwgCeLHXl
/DG3WHjOB4Z8Kb1AXifKLqE=
=VpkL
-END PGP SIGNATURE-

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Logging all data sent to client

2007-07-25 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Ben,

ben short wrote:
> I ripped and altered the code of the Compression Filter servlet
> example from tomcat 5.5.23.

Okay. I haven't seen that example; I was just commenting on your post.

> There is no LoggingServletWriter, if you look in the original
> getWriter method the ServletOutputStream is wrapped by a PrintWriter.

Right. I was suggesting that you use whatever super.getWriter gives you,
instead of avoiding the upstream code.

> So your proposed change of the getWriter method to the following would
> result in the ServletOutputStream not being used if the client of the
> LoggingHttpServletResponse called the getWriter method and thus no
> logging of the response.

Well... if you wrap both (separately) the ServletOutputStream and
Writer, then you will get your logging.

> So saying that the finishResponse method change is not valid also. As
> the writer flush method should be called if a writer was created,
> which in turn will call the stream it has wrapped flush method.

Flushing should occur regardless of whether the user used a stream or a
writer. But, it's not up to you to call flush()... it's up to the
servlet code to do that.

The code you posted (granted, as an adaptation of an example found
online) was less of a wrapper and more of a blocker. It replaced
functionality supplied in the superclass instead of filtering it. I
would have the same criticism of the example. Perhaps I'll post what I
believe to be a superior example and see if the documentation
powers-that-be agree.

- -chris

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGp7H99CaO5/Lv0PARAmMoAJ9YgQVQc9oYXY/8WPSKdVmy4RXcrgCgluj7
2ShArNw0TujAheDYN4IVUzw=
=J3px
-END PGP SIGNATURE-

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Logging all data sent to client

2007-07-25 Thread ben short

Hi Christopher,

I ripped and altered the code of the Compression Filter servlet
example from tomcat 5.5.23.

There is no LoggingServletWriter, if you look in the original
getWriter method the ServletOutputStream is wrapped by a PrintWriter.
So your proposed change of the getWriter method to the following would
result in the ServletOutputStream not being used if the client of the
LoggingHttpServletResponse called the getWriter method and thus no
logging of the response.

public PrintWriter getWriter() throws IOException
{
  if(null == mWriter)
   mWriter = new LoggingServletWriter(super.getWriter());

  return mWriter;
}

So saying that the finishResponse method change is not valid also. As
the writer flush method should be called if a writer was created,
which in turn will call the stream it has wrapped flush method.

I agree that the check to see if the logger is enabled in the close
method is not needed, and well spotted about the NPE.

Regards

Ben

On 7/25/07, Christopher Schultz <[EMAIL PROTECTED]> wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Ben,

I might change your LoggingHttpServletResponse slightly. I think it's
more complicated than necessary.

ben short wrote:
> LoggingHttpServletResponse.java
>
> class LoggingHttpServletResponse extends HttpServletResponseWrapper
>{
>private Logger mLogger =
> Logger.getLogger(LoggingHttpServletResponse.class);
>
>public LoggingHttpServletResponse(HttpServletResponse
> httpServletResponse)
>{
>super(httpServletResponse);
>mWrappedResponse = httpServletResponse;

// I would remove the mWrappedResponse. You can always call
super.getResponse to get the wrapped response.

>}

[snip]

>// - Public
> Methods
>
>/**
> * Create and return a ServletOutputStream to write the content
> * associated with this Response.
> *
> * @throws IOException if an input/output error occurs
> */
>public ServletOutputStream createOutputStream() throws IOException
>{
>mLogger.debug("Creating new LoggingOutputStream");
>
>return new LoggingServletOutputStream(mWrappedResponse, mLogger);
>}

Is this method useful? The constructor for LSOS ought to be enough.

>/**
> * Finish a response.
> */
>public void finishResponse()
>{
>try
>{
>if (mWriter != null)
>{
>mWriter.close();
>}
>else
>{
>if (mStream != null)
>mStream.close();
>}
>}
>catch (IOException e)
>{
>}
>}

Same here. You should not need a finishResponse method. You ought to
allow the 'close' method to do its job. Remove this method.

>/**
> * Flush the buffer and commit this response.
> *
> * @throws IOException if an input/output error occurs
> */
>public void flushBuffer() throws IOException
>{
>mStream.flush();
>}

How about:

public void flushBuffer()
throws IOException
{
if(null != mStream)
   mStream.flush();
else if(null != mWriter)
   mWriter.flush();
}

>public ServletOutputStream getOutputStream() throws IOException
>{
>if (mWriter != null)
>throw new IllegalStateException("getWriter() has already
> been called for this response");
>
>if (mStream == null)
>mStream = createOutputStream();
>
>mLogger.debug("mStream is set to " + mStream + " in
> getOutputStream");
>
>return (mStream);
>}

This method should be:

public ServletOutputStream getOutputStream()
{
if(null == mStream)
mStream = new LoggingServletOutputStream(super.getOutputStream));

return mStream;
}

>public PrintWriter getWriter() throws IOException
>{
>if (mWriter != null)
>return (mWriter);
>
>if (mStream != null)
>throw new IllegalStateException("getOutputStream() has
> already been called for this response");
>
>mStream = createOutputStream();
>
>mLogger.debug("mStream is set to " + mStream + " in
> getOutputStream");
>
>// HttpServletResponse.getCharacterEncoding() shouldn't return null
>// according the spec, so feel free to remove that "if"
>mWriter = new PrintWriter(mStream);
>
>return (mWriter);
>}
>}

Similarly:

public PrintWriter getWriter()
   throws IOException
{
if(null == mWriter)
 mWriter = new LoggingServletWriter(super.getWriter());

return mWriter;
}


> LoggingServletOutputStream.java
>
> class LoggingServletOutputStream extends ServletOutputStream
>{
>private Logger mLogger;
>private HttpServletResponse mResponse;

The response is not necessary. Remove this.

>private OutputStream mOutputStream;
>private ByteArrayOutputStream mBy

Re: Logging all data sent to client

2007-07-25 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Ben,

I might change your LoggingHttpServletResponse slightly. I think it's
more complicated than necessary.

ben short wrote:
> LoggingHttpServletResponse.java
> 
> class LoggingHttpServletResponse extends HttpServletResponseWrapper
>{
>private Logger mLogger =
> Logger.getLogger(LoggingHttpServletResponse.class);
> 
>public LoggingHttpServletResponse(HttpServletResponse
> httpServletResponse)
>{
>super(httpServletResponse);
>mWrappedResponse = httpServletResponse;

// I would remove the mWrappedResponse. You can always call
super.getResponse to get the wrapped response.

>}

[snip]

>// - Public
> Methods
> 
>/**
> * Create and return a ServletOutputStream to write the content
> * associated with this Response.
> *
> * @throws IOException if an input/output error occurs
> */
>public ServletOutputStream createOutputStream() throws IOException
>{
>mLogger.debug("Creating new LoggingOutputStream");
> 
>return new LoggingServletOutputStream(mWrappedResponse, mLogger);
>}

Is this method useful? The constructor for LSOS ought to be enough.

>/**
> * Finish a response.
> */
>public void finishResponse()
>{
>try
>{
>if (mWriter != null)
>{
>mWriter.close();
>}
>else
>{
>if (mStream != null)
>mStream.close();
>}
>}
>catch (IOException e)
>{
>}
>}

Same here. You should not need a finishResponse method. You ought to
allow the 'close' method to do its job. Remove this method.

>/**
> * Flush the buffer and commit this response.
> *
> * @throws IOException if an input/output error occurs
> */
>public void flushBuffer() throws IOException
>{
>mStream.flush();
>}

How about:

public void flushBuffer()
throws IOException
{
if(null != mStream)
   mStream.flush();
else if(null != mWriter)
   mWriter.flush();
}

>public ServletOutputStream getOutputStream() throws IOException
>{
>if (mWriter != null)
>throw new IllegalStateException("getWriter() has already
> been called for this response");
> 
>if (mStream == null)
>mStream = createOutputStream();
> 
>mLogger.debug("mStream is set to " + mStream + " in
> getOutputStream");
> 
>return (mStream);
>}

This method should be:

public ServletOutputStream getOutputStream()
{
if(null == mStream)
mStream = new LoggingServletOutputStream(super.getOutputStream));

return mStream;
}

>public PrintWriter getWriter() throws IOException
>{
>if (mWriter != null)
>return (mWriter);
> 
>if (mStream != null)
>throw new IllegalStateException("getOutputStream() has
> already been called for this response");
> 
>mStream = createOutputStream();
> 
>mLogger.debug("mStream is set to " + mStream + " in
> getOutputStream");
> 
>// HttpServletResponse.getCharacterEncoding() shouldn't return null
>// according the spec, so feel free to remove that "if"
>mWriter = new PrintWriter(mStream);
> 
>return (mWriter);
>}
>}

Similarly:

public PrintWriter getWriter()
   throws IOException
{
if(null == mWriter)
 mWriter = new LoggingServletWriter(super.getWriter());

return mWriter;
}


> LoggingServletOutputStream.java
> 
> class LoggingServletOutputStream extends ServletOutputStream
>{
>private Logger mLogger;
>private HttpServletResponse mResponse;

The response is not necessary. Remove this.

>private OutputStream mOutputStream;
>private ByteArrayOutputStream mByteArrayOutputStream = new
> ByteArrayOutputStream();

Good.

>public LoggingServletOutputStream(HttpServletResponse response,
> Logger logger) throws IOException
>{
>mResponse = response;
>mOutputStream = mResponse.getOutputStream();
>mLogger = logger;
>}

Remove the response object, and replace it with the output stream directly.

>public void write(int b) throws IOException
>{
>mByteArrayOutputStream.write(b);
>mOutputStream.write(b);
>}
> 
>@Override
>public void write(byte b[]) throws IOException
>{
>mByteArrayOutputStream.write(b);
>mOutputStream.write(b);
>}
>
>@Override
>public void write(byte b[], int off, int len) throws IOException
>{
>mByteArrayOutputStream.write(b, off, len);
>mOutputStream.write(b, off, len);
>}

Good.

>@Override
>public void close() throws IOException
>{
>if ( mLogger.isDebugEnabled() )

You p

Re: Logging all data sent to client

2007-07-25 Thread Karel V Sedlacek
Thanks Ben!

> Heres what I have put together, use at your own risk. any comments
> welcome.
>
> HttpServletResponseLoggingFilter.java
>
> public class HttpServletResponseLoggingFilter implements Filter
> {
> private Logger mLogger =
> Logger.getLogger(HttpServletResponseLoggingFilter.class);
>
> public void doFilter(ServletRequest servletRequest,
> ServletResponse servletResponse, FilterChain filterChain) throws
> IOException, ServletException
> {
> if ( mLogger.isDebugEnabled() && servletResponse instanceof
> HttpServletResponse &&
> isNonStaticResource((HttpServletRequest)servletRequest) )
> {
> final LoggingHttpServletResponse
> loggingHttpServletResponse = new
> LoggingHttpServletResponse((HttpServletResponse)servletResponse);
>
> try
> {
> mLogger.debug("Filtering request : " +
> getFullRequestUrl((HttpServletRequest)servletRequest));
>
> filterChain.doFilter(servletRequest,
> loggingHttpServletResponse);
> }
> finally
> {
> loggingHttpServletResponse.finishResponse();
> }
> }
> else
> {
> filterChain.doFilter(servletRequest, servletResponse);
> }
> }
>
> private boolean isNonStaticResource(HttpServletRequest request)
> {
> return !request.getRequestURI().contains("resources");
> }
>
> // http://hostname.com/mywebapp/servlet/MyServlet/a/b;c=123?d=789
> private String getFullRequestUrl(HttpServletRequest request)
> {
> String reqUrl = request.getRequestURL().toString();
> String queryString = request.getQueryString();   // d=789
> if (queryString != null)
> {
> reqUrl += "?"+queryString;
> }
> return reqUrl;
> }
>
> public void init(FilterConfig filterConfig) throws ServletException
> {
> }
>
> public void destroy()
> {
> }
>
> }
>
> LoggingHttpServletResponse.java
>
> class LoggingHttpServletResponse extends HttpServletResponseWrapper
> {
> private Logger mLogger =
> Logger.getLogger(LoggingHttpServletResponse.class);
>
> public LoggingHttpServletResponse(HttpServletResponse
> httpServletResponse)
> {
> super(httpServletResponse);
> mWrappedResponse = httpServletResponse;
> }
>
> // - Instance
> Variables
>
> /**
>  * Original response
>  */
>
> protected HttpServletResponse mWrappedResponse = null;
>
> /**
>  * The ServletOutputStream that has been returned by
>  * getOutputStream(), if any.
>  */
>
> protected ServletOutputStream mStream = null;
>
>
> /**
>  * The PrintWriter that has been returned by
>  * getWriter(), if any.
>  */
>
> protected PrintWriter mWriter = null;
>
> // - Public
> Methods
>
> /**
>  * Create and return a ServletOutputStream to write the content
>  * associated with this Response.
>  *
>  * @throws IOException if an input/output error occurs
>  */
> public ServletOutputStream createOutputStream() throws IOException
> {
> mLogger.debug("Creating new LoggingOutputStream");
>
> return new LoggingServletOutputStream(mWrappedResponse, mLogger);
> }
>
>
> /**
>  * Finish a response.
>  */
> public void finishResponse()
> {
> try
> {
> if (mWriter != null)
> {
> mWriter.close();
> }
> else
> {
> if (mStream != null)
> mStream.close();
> }
> }
> catch (IOException e)
> {
> }
> }
>
> //  ServletResponse
> Methods
>
>
> /**
>  * Flush the buffer and commit this response.
>  *
>  * @throws IOException if an input/output error occurs
>  */
> public void flushBuffer() throws IOException
> {
> mStream.flush();
> }
>
> /**
>  * Return the servlet output mStream associated with this Response.
>  *
>  * @throws IllegalStateException if getWriter has
>  *   already been called for this response
>  * @throws IOException   if an input/output error occurs
>  */
> public ServletOutputStream getOutputStream() throws IOException
> {
> if (mWriter != null)
> throw new IllegalStateException("getWriter() has already
> been called for this response");
>
> if (mStream == null)
> mStream = createOutputStream();
>
> mLogger.debug("mStream is set to " + mStream + " in
> get

Re: Logging all data sent to client

2007-07-24 Thread ben short

Heres what I have put together, use at your own risk. any comments welcome.

HttpServletResponseLoggingFilter.java

public class HttpServletResponseLoggingFilter implements Filter
   {
   private Logger mLogger =
Logger.getLogger(HttpServletResponseLoggingFilter.class);

   public void doFilter(ServletRequest servletRequest,
ServletResponse servletResponse, FilterChain filterChain) throws
IOException, ServletException
   {
   if ( mLogger.isDebugEnabled() && servletResponse instanceof
HttpServletResponse &&
isNonStaticResource((HttpServletRequest)servletRequest) )
   {
   final LoggingHttpServletResponse
loggingHttpServletResponse = new
LoggingHttpServletResponse((HttpServletResponse)servletResponse);

   try
   {
   mLogger.debug("Filtering request : " +
getFullRequestUrl((HttpServletRequest)servletRequest));

   filterChain.doFilter(servletRequest,
loggingHttpServletResponse);
   }
   finally
   {
   loggingHttpServletResponse.finishResponse();
   }
   }
   else
   {
   filterChain.doFilter(servletRequest, servletResponse);
   }
   }

   private boolean isNonStaticResource(HttpServletRequest request)
   {
   return !request.getRequestURI().contains("resources");
   }

   // http://hostname.com/mywebapp/servlet/MyServlet/a/b;c=123?d=789
   private String getFullRequestUrl(HttpServletRequest request)
   {
   String reqUrl = request.getRequestURL().toString();
   String queryString = request.getQueryString();   // d=789
   if (queryString != null)
   {
   reqUrl += "?"+queryString;
   }
   return reqUrl;
   }

   public void init(FilterConfig filterConfig) throws ServletException
   {
   }

   public void destroy()
   {
   }

   }

LoggingHttpServletResponse.java

class LoggingHttpServletResponse extends HttpServletResponseWrapper
   {
   private Logger mLogger = Logger.getLogger(LoggingHttpServletResponse.class);

   public LoggingHttpServletResponse(HttpServletResponse httpServletResponse)
   {
   super(httpServletResponse);
   mWrappedResponse = httpServletResponse;
   }

   // - Instance Variables

   /**
* Original response
*/

   protected HttpServletResponse mWrappedResponse = null;

   /**
* The ServletOutputStream that has been returned by
* getOutputStream(), if any.
*/

   protected ServletOutputStream mStream = null;


   /**
* The PrintWriter that has been returned by
* getWriter(), if any.
*/

   protected PrintWriter mWriter = null;

   // - Public Methods

   /**
* Create and return a ServletOutputStream to write the content
* associated with this Response.
*
* @throws IOException if an input/output error occurs
*/
   public ServletOutputStream createOutputStream() throws IOException
   {
   mLogger.debug("Creating new LoggingOutputStream");

   return new LoggingServletOutputStream(mWrappedResponse, mLogger);
   }


   /**
* Finish a response.
*/
   public void finishResponse()
   {
   try
   {
   if (mWriter != null)
   {
   mWriter.close();
   }
   else
   {
   if (mStream != null)
   mStream.close();
   }
   }
   catch (IOException e)
   {
   }
   }

   //  ServletResponse Methods


   /**
* Flush the buffer and commit this response.
*
* @throws IOException if an input/output error occurs
*/
   public void flushBuffer() throws IOException
   {
   mStream.flush();
   }

   /**
* Return the servlet output mStream associated with this Response.
*
* @throws IllegalStateException if getWriter has
*   already been called for this response
* @throws IOException   if an input/output error occurs
*/
   public ServletOutputStream getOutputStream() throws IOException
   {
   if (mWriter != null)
   throw new IllegalStateException("getWriter() has already
been called for this response");

   if (mStream == null)
   mStream = createOutputStream();

   mLogger.debug("mStream is set to " + mStream + " in getOutputStream");

   return (mStream);
   }

   /**
* Return the mWriter associated with this Response.
*
* @throws IllegalStateException if getOutputStream has
*   already been called for this response
* @throws IOException   if an input/output error occurs
*/
   public PrintWriter getWriter() throws IOException
   {
   if (mWriter != null)
   return (mWriter);

   i

Re: Logging all data sent to client

2007-07-24 Thread ben short

Yes sure.

On 7/24/07, Karel V Sedlacek <[EMAIL PROTECTED]> wrote:

Ben,

When you succeed at this would you pass along your code?  We have issues
with timeouts and it would be great to see what's being passed along to
the client.

Karel
Cornell University

> Yes from the CompressionServletResponseWrapper example I can see the
> methods I need to override as you have pointed out.
>
> On 7/24/07, Tim Funk <[EMAIL PROTECTED]> wrote:
>> Yes - but tomcat doesn't have that functionality out of the box - you'd
>> need to write a filter which creates a HttpServletRequestWrapper which
>> overrides getOutputStream() (or getWriter()) and then passes back a
>> wrapped OutStream or Writer which also logs to wherever when print(int
>> i) is called.
>>
>> -Tim
>>
>> ben short wrote:
>> > Hi Tim,
>> >
>> > Thanks for that, but it only seems to log out the request/response
>> > headers. Is It possible to log everything sent to the client?
>> >
>> > Ben
>> >
>> > On 7/24/07, Tim Funk <[EMAIL PROTECTED]> wrote:
>> >> Look at the RequestDumperValve
>> >>
>> >> -Tim
>> >>
>> >> ben short wrote:
>> >> > Hi,
>> >> >
>> >> > I using Tomcat 6.0.13 and Spring 2.0.6. I have been involved in
>> >> > developing a website that products pages in various formats , such
>> as
>> >> > www, xml, wap and pda. We are having some issues with wap and pda,
>> but
>> >> > cant ciew the html source thats being shown on the devices.
>> >> > We can view the html source in firefox using a wap and pda plugin,
>> but
>> >> > the issues are not always the same or there at all.
>> >> >
>> >> > What I would like to do is log all the data sent to the client. I
>> have
>> >> > been looking at encapsulating the HttpServletRequest and log out
>> the
>> >> > data to a log file.
>>
>> -
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
> -
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Logging all data sent to client

2007-07-24 Thread Karel V Sedlacek
Ben,

When you succeed at this would you pass along your code?  We have issues
with timeouts and it would be great to see what's being passed along to
the client.

Karel
Cornell University

> Yes from the CompressionServletResponseWrapper example I can see the
> methods I need to override as you have pointed out.
>
> On 7/24/07, Tim Funk <[EMAIL PROTECTED]> wrote:
>> Yes - but tomcat doesn't have that functionality out of the box - you'd
>> need to write a filter which creates a HttpServletRequestWrapper which
>> overrides getOutputStream() (or getWriter()) and then passes back a
>> wrapped OutStream or Writer which also logs to wherever when print(int
>> i) is called.
>>
>> -Tim
>>
>> ben short wrote:
>> > Hi Tim,
>> >
>> > Thanks for that, but it only seems to log out the request/response
>> > headers. Is It possible to log everything sent to the client?
>> >
>> > Ben
>> >
>> > On 7/24/07, Tim Funk <[EMAIL PROTECTED]> wrote:
>> >> Look at the RequestDumperValve
>> >>
>> >> -Tim
>> >>
>> >> ben short wrote:
>> >> > Hi,
>> >> >
>> >> > I using Tomcat 6.0.13 and Spring 2.0.6. I have been involved in
>> >> > developing a website that products pages in various formats , such
>> as
>> >> > www, xml, wap and pda. We are having some issues with wap and pda,
>> but
>> >> > cant ciew the html source thats being shown on the devices.
>> >> > We can view the html source in firefox using a wap and pda plugin,
>> but
>> >> > the issues are not always the same or there at all.
>> >> >
>> >> > What I would like to do is log all the data sent to the client. I
>> have
>> >> > been looking at encapsulating the HttpServletRequest and log out
>> the
>> >> > data to a log file.
>>
>> -
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
> -
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Logging all data sent to client

2007-07-24 Thread ben short

Yes from the CompressionServletResponseWrapper example I can see the
methods I need to override as you have pointed out.

On 7/24/07, Tim Funk <[EMAIL PROTECTED]> wrote:

Yes - but tomcat doesn't have that functionality out of the box - you'd
need to write a filter which creates a HttpServletRequestWrapper which
overrides getOutputStream() (or getWriter()) and then passes back a
wrapped OutStream or Writer which also logs to wherever when print(int
i) is called.

-Tim

ben short wrote:
> Hi Tim,
>
> Thanks for that, but it only seems to log out the request/response
> headers. Is It possible to log everything sent to the client?
>
> Ben
>
> On 7/24/07, Tim Funk <[EMAIL PROTECTED]> wrote:
>> Look at the RequestDumperValve
>>
>> -Tim
>>
>> ben short wrote:
>> > Hi,
>> >
>> > I using Tomcat 6.0.13 and Spring 2.0.6. I have been involved in
>> > developing a website that products pages in various formats , such as
>> > www, xml, wap and pda. We are having some issues with wap and pda, but
>> > cant ciew the html source thats being shown on the devices.
>> > We can view the html source in firefox using a wap and pda plugin, but
>> > the issues are not always the same or there at all.
>> >
>> > What I would like to do is log all the data sent to the client. I have
>> > been looking at encapsulating the HttpServletRequest and log out the
>> > data to a log file.

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Logging all data sent to client

2007-07-24 Thread Tim Funk
Yes - but tomcat doesn't have that functionality out of the box - you'd 
need to write a filter which creates a HttpServletRequestWrapper which 
overrides getOutputStream() (or getWriter()) and then passes back a 
wrapped OutStream or Writer which also logs to wherever when print(int 
i) is called.


-Tim

ben short wrote:

Hi Tim,

Thanks for that, but it only seems to log out the request/response
headers. Is It possible to log everything sent to the client?

Ben

On 7/24/07, Tim Funk <[EMAIL PROTECTED]> wrote:

Look at the RequestDumperValve

-Tim

ben short wrote:
> Hi,
>
> I using Tomcat 6.0.13 and Spring 2.0.6. I have been involved in
> developing a website that products pages in various formats , such as
> www, xml, wap and pda. We are having some issues with wap and pda, but
> cant ciew the html source thats being shown on the devices.
> We can view the html source in firefox using a wap and pda plugin, but
> the issues are not always the same or there at all.
>
> What I would like to do is log all the data sent to the client. I have
> been looking at encapsulating the HttpServletRequest and log out the
> data to a log file.


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Logging all data sent to client

2007-07-24 Thread Jon Wingfield

I don't think there is an out of the box valve for doing this.
However, it shouldn't be too much work to use a Filter to wrap the 
response (and it's outputstream/writer) so that as the data is pumped to 
the client it is also written to a log.
Obviously, for the log to make sense entire responses should be 
contiguous, which may (will) have a performance impact...


ben short wrote:

Hi Tim,

Thanks for that, but it only seems to log out the request/response
headers. Is It possible to log everything sent to the client?

Ben

On 7/24/07, Tim Funk <[EMAIL PROTECTED]> wrote:

Look at the RequestDumperValve

-Tim

ben short wrote:
> Hi,
>
> I using Tomcat 6.0.13 and Spring 2.0.6. I have been involved in
> developing a website that products pages in various formats , such as
> www, xml, wap and pda. We are having some issues with wap and pda, but
> cant ciew the html source thats being shown on the devices.
> We can view the html source in firefox using a wap and pda plugin, but
> the issues are not always the same or there at all.
>
> What I would like to do is log all the data sent to the client. I have
> been looking at encapsulating the HttpServletRequest and log out the
> data to a log file.
>
> Is there any easier way to do this with tomcat?
>

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Logging all data sent to client

2007-07-24 Thread ben short

I was just looking at the compressionFilter example. Its doing along
the lines of what I want todo.

Thank you all.


On 7/24/07, Titi Wangsa <[EMAIL PROTECTED]> wrote:

create a httpservlet filter?

On 7/24/07, ben short <[EMAIL PROTECTED]> wrote:
> Hi Tim,
>
> Thanks for that, but it only seems to log out the request/response
> headers. Is It possible to log everything sent to the client?
>
> Ben
>
> On 7/24/07, Tim Funk <[EMAIL PROTECTED]> wrote:
> > Look at the RequestDumperValve
> >
> > -Tim
> >
> > ben short wrote:
> > > Hi,
> > >
> > > I using Tomcat 6.0.13 and Spring 2.0.6. I have been involved in
> > > developing a website that products pages in various formats , such as
> > > www, xml, wap and pda. We are having some issues with wap and pda, but
> > > cant ciew the html source thats being shown on the devices.
> > > We can view the html source in firefox using a wap and pda plugin, but
> > > the issues are not always the same or there at all.
> > >
> > > What I would like to do is log all the data sent to the client. I have
> > > been looking at encapsulating the HttpServletRequest and log out the
> > > data to a log file.
> > >
> > > Is there any easier way to do this with tomcat?
> > >
> >
> > -
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
> -
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Logging all data sent to client

2007-07-24 Thread ben short

Hi Tim,

Thanks for that, but it only seems to log out the request/response
headers. Is It possible to log everything sent to the client?

Ben

On 7/24/07, Tim Funk <[EMAIL PROTECTED]> wrote:

Look at the RequestDumperValve

-Tim

ben short wrote:
> Hi,
>
> I using Tomcat 6.0.13 and Spring 2.0.6. I have been involved in
> developing a website that products pages in various formats , such as
> www, xml, wap and pda. We are having some issues with wap and pda, but
> cant ciew the html source thats being shown on the devices.
> We can view the html source in firefox using a wap and pda plugin, but
> the issues are not always the same or there at all.
>
> What I would like to do is log all the data sent to the client. I have
> been looking at encapsulating the HttpServletRequest and log out the
> data to a log file.
>
> Is there any easier way to do this with tomcat?
>

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Logging all data sent to client

2007-07-24 Thread Titi Wangsa

create a httpservlet filter?

On 7/24/07, ben short <[EMAIL PROTECTED]> wrote:

Hi Tim,

Thanks for that, but it only seems to log out the request/response
headers. Is It possible to log everything sent to the client?

Ben

On 7/24/07, Tim Funk <[EMAIL PROTECTED]> wrote:
> Look at the RequestDumperValve
>
> -Tim
>
> ben short wrote:
> > Hi,
> >
> > I using Tomcat 6.0.13 and Spring 2.0.6. I have been involved in
> > developing a website that products pages in various formats , such as
> > www, xml, wap and pda. We are having some issues with wap and pda, but
> > cant ciew the html source thats being shown on the devices.
> > We can view the html source in firefox using a wap and pda plugin, but
> > the issues are not always the same or there at all.
> >
> > What I would like to do is log all the data sent to the client. I have
> > been looking at encapsulating the HttpServletRequest and log out the
> > data to a log file.
> >
> > Is there any easier way to do this with tomcat?
> >
>
> -
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Logging all data sent to client

2007-07-24 Thread Tim Funk

Look at the RequestDumperValve

-Tim

ben short wrote:

Hi,

I using Tomcat 6.0.13 and Spring 2.0.6. I have been involved in
developing a website that products pages in various formats , such as
www, xml, wap and pda. We are having some issues with wap and pda, but
cant ciew the html source thats being shown on the devices.
We can view the html source in firefox using a wap and pda plugin, but
the issues are not always the same or there at all.

What I would like to do is log all the data sent to the client. I have
been looking at encapsulating the HttpServletRequest and log out the
data to a log file.

Is there any easier way to do this with tomcat?



-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]