You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Frank W. Zammetti" <fz...@omnytex.com> on 2006/02/21 17:40:24 UTC

Re: How to print request headers and sessin attributes log4j logging

Have a look at this:

http://javawebparts.sourceforge.net/javadocs/javawebparts/request/RequestHelpers.html#logAllRequestInfo(javax.servlet.http.HttpServletRequest)

This is a method in the RequestHelpers class in Java Web Parts
(http://javawebparts.sourceforge.net).  Since it uses JCL for logging, you
can configure log4j underneath as appropriate and get what you want (a
little more actually- this gives you request attributes, headers and
parameters).

For the session attributes:

http://javawebparts.sourceforge.net/javadocs/javawebparts/session/SessionHelpers.html#logSessionAttributes(javax.servlet.http.HttpSession)

Same thing basically: SessionHelpers.logSessionAttributes()

Incidentally, there are methods in these two classes that return just the
request attributes, just the headers, just the parameters, etc., and
return them as a Map, so you can just do:

log.info(RequestHelpers.getRequestAttributes(request));

...if that's all you really want.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: fzammetti@hotmail.com

On Tue, February 21, 2006 11:25 am, Mark Womack said:
> See the documentation for the MDC class.  You will need to do some
> setup via a servlet Filter or other mechanism, and it will only apply
> to the thread handling the request.
>
> hth,
> -Mark
>
> On 2/18/06, sreenivas velagapudi <sr...@yahoo.com> wrote:
>> Hi,
>>     Is there any way i can print the request header
>> messages and all the session attributes through log4j
>> logging .
>> when i click any link.
>>
>> Please help me out.
>>
>> Thanks
>> Sreenivas
>>
>>
>>
>>
>>
>> __________________________________
>> Do you Yahoo!?
>> New and Improved Yahoo! Mail - 1GB free storage!
>> http://sg.whatsnew.mail.yahoo.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>
>


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