You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Eric Giguere <er...@videotron.ca> on 2003/08/14 21:00:41 UTC

Configuring jdk14 logging under tomcat

Hi all

I've search for the last hour to get a way to configure the jdk1.4 
logging facility when used from the commons-logging, all this running 
under Tomcat 4.1.24
 From jdk doc, we can either call configure() method (cannot), modify 
system wide config file (don't want) of supply a config file path as a 
JVM system property. I've not found how to do so on web-application 
startup, using web.xml tags <env-entry> and <context-param> failed... Or 
did I miss something?

My question is then, is it possible to configure the jdk1.4 logging 
engine used from commons-logging in a web application context? If so, 
anybody can help with some general advice?

Meanwhile, commons-logging.properties in WEB-INF/classes and 
simplelog.properties in same location allowed me to get debug messages.

Any help appreciated
thx

Eric



RE: Configuring jdk14 logging under tomcat

Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Tue, 19 Aug 2003, Eric Giguere wrote:

> Date: Tue, 19 Aug 2003 10:48:41 -0400
> From: Eric Giguere <er...@videotron.ca>
> Reply-To: Jakarta Commons Users List <co...@jakarta.apache.org>
> To: Jakarta Commons Users List <co...@jakarta.apache.org>
> Subject: RE: Configuring jdk14 logging under tomcat
>
> Hi Craig
>
> Euh, can I say here that I'm honored to have you answering one of my
> questions. I'm following with great interest all your work on both Tomcat,
> Struts and particulary on the standardization efforts for the Java Server
> Faces.
>
> Yes, its been quite clear in all the documentation that the configuration of
> the underlying log engine encapsultated by commons-logging is up to the
> programmer, using the underlying mechanism to do so. But since there is
> already a dependancy between commons-logging and Jdk1.4 logging package,

It is not really a dependency -- it's just one of the possible logging
implementations that can be used.

> I'm
> wondering if it would be desirable to add some pre-coded configuration
> mechanism in the Jdk14Logger, something like using of a property file like
> the mechanism coded in the static initializer of the SimpleLog class for
> instance.
>

I think this would be a really really bad idea.  The whole point of
commons-logging is to be a portable wrapper around the *logging* calls,
not around the *configuration* calls.

> If not, like you mentionned, coding the LogManager.readConfiguration() in
> the ServletContextListener do the trick. Adding a search for the property
> file ( the jdk14.properties... like simplelog.properties ) and calling this
> method with the found file, would it be a violation of the philosophy of
> commons-logging?

Yes.

When you make the choice that "this particular app is going to use JDK
1.4" logging, you are also taking the responsibility to configure it
appropriately.  Later, if you change your mind and want to use Log4J
instead, then all you need to do is tweak the configuration stuff -- the
logging calls stay the same.  That is all commons-logging was ever
intended to do, and any attempt to get into configuration will just be
duplicating facilities that the logging implementations already provide.

>
> Thx again.
> Eric.

Craig

RE: Configuring jdk14 logging under tomcat

Posted by Eric Giguere <er...@videotron.ca>.
Hi Craig

Euh, can I say here that I'm honored to have you answering one of my
questions. I'm following with great interest all your work on both Tomcat,
Struts and particulary on the standardization efforts for the Java Server
Faces.

Yes, its been quite clear in all the documentation that the configuration of
the underlying log engine encapsultated by commons-logging is up to the
programmer, using the underlying mechanism to do so. But since there is
already a dependancy between commons-logging and Jdk1.4 logging package, I'm
wondering if it would be desirable to add some pre-coded configuration
mechanism in the Jdk14Logger, something like using of a property file like
the mechanism coded in the static initializer of the SimpleLog class for
instance.

If not, like you mentionned, coding the LogManager.readConfiguration() in
the ServletContextListener do the trick. Adding a search for the property
file ( the jdk14.properties... like simplelog.properties ) and calling this
method with the found file, would it be a violation of the philosophy of
commons-logging?

Thx again.
Eric.



-----Original Message-----
From: Craig R. McClanahan [mailto:craigmcc@apache.org]
Sent: August 16, 2003 10:07 PM
To: Jakarta Commons Users List
Subject: Re: Configuring jdk14 logging under tomcat


On Thu, 14 Aug 2003, Eric Giguere wrote:

> Date: Thu, 14 Aug 2003 15:00:41 -0400
> From: Eric Giguere <er...@videotron.ca>
> Reply-To: Jakarta Commons Users List <co...@jakarta.apache.org>
> To: commons-user@jakarta.apache.org
> Subject: Configuring jdk14 logging under tomcat
>
> Hi all
>
> I've search for the last hour to get a way to configure the jdk1.4
> logging facility when used from the commons-logging, all this running
> under Tomcat 4.1.24
>  From jdk doc, we can either call configure() method (cannot), modify
> system wide config file (don't want) of supply a config file path as a
> JVM system property. I've not found how to do so on web-application
> startup, using web.xml tags <env-entry> and <context-param> failed... Or
> did I miss something?
>
> My question is then, is it possible to configure the jdk1.4 logging
> engine used from commons-logging in a web application context? If so,
> anybody can help with some general advice?
>

The two basic mechanisms for configuring JDK 1.4 logging (similar in
philosphy to other logging implementations) are programmatic setup and
configuration file processing, so those are your two basic choices.

* For programmatic setup, you'll want to acquire the LogManager
  instance and perform the appropriate configuration.  In a webapp,
  it's probably best to do this sort of thing in a ServletContextListener
  if you're on a Servlet 2.3 container (which includes Tomcat 4.1.x).

* For configuration-based setup, you can specify the appropriate config
  files via system properties or by calling LogManager.readConfiguration()
  yourself.

> Meanwhile, commons-logging.properties in WEB-INF/classes and
> simplelog.properties in same location allowed me to get debug messages.
>

The general philosophy of commons-logging is that configuration of the
underlying logging implementation should be done through that
implementation's normal facilities.  Since SimpleLog *is* a logging
implementation, it offers its own ability to configure itself, but if you
want to use JDK 1.4 or Log4J logging, you'll need to use the standard
configuration facilities provided by those systems.

> Any help appreciated
> thx
>
> Eric

Craig

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: Configuring jdk14 logging under tomcat

Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Thu, 14 Aug 2003, Eric Giguere wrote:

> Date: Thu, 14 Aug 2003 15:00:41 -0400
> From: Eric Giguere <er...@videotron.ca>
> Reply-To: Jakarta Commons Users List <co...@jakarta.apache.org>
> To: commons-user@jakarta.apache.org
> Subject: Configuring jdk14 logging under tomcat
>
> Hi all
>
> I've search for the last hour to get a way to configure the jdk1.4
> logging facility when used from the commons-logging, all this running
> under Tomcat 4.1.24
>  From jdk doc, we can either call configure() method (cannot), modify
> system wide config file (don't want) of supply a config file path as a
> JVM system property. I've not found how to do so on web-application
> startup, using web.xml tags <env-entry> and <context-param> failed... Or
> did I miss something?
>
> My question is then, is it possible to configure the jdk1.4 logging
> engine used from commons-logging in a web application context? If so,
> anybody can help with some general advice?
>

The two basic mechanisms for configuring JDK 1.4 logging (similar in
philosphy to other logging implementations) are programmatic setup and
configuration file processing, so those are your two basic choices.

* For programmatic setup, you'll want to acquire the LogManager
  instance and perform the appropriate configuration.  In a webapp,
  it's probably best to do this sort of thing in a ServletContextListener
  if you're on a Servlet 2.3 container (which includes Tomcat 4.1.x).

* For configuration-based setup, you can specify the appropriate config
  files via system properties or by calling LogManager.readConfiguration()
  yourself.

> Meanwhile, commons-logging.properties in WEB-INF/classes and
> simplelog.properties in same location allowed me to get debug messages.
>

The general philosophy of commons-logging is that configuration of the
underlying logging implementation should be done through that
implementation's normal facilities.  Since SimpleLog *is* a logging
implementation, it offers its own ability to configure itself, but if you
want to use JDK 1.4 or Log4J logging, you'll need to use the standard
configuration facilities provided by those systems.

> Any help appreciated
> thx
>
> Eric

Craig

[HttpClient] 400 Bad Request

Posted by Ed Ludke <ed...@yahoo.com>.
Hey all,

I'm trying to log into a several different sites and I've had success
with 2 outta 3.  The third gives me a 400 Bad Request and I'm not quite
sure why.  The response to the actual POST looks ok, but something goes
wrong with the redirects.  My test code is based on FormLoginDemo.java
that comes with the examples and I tried to change just the part that
was specific to the site that was being hit.

If anyone knows why I might be having a problem here, your help would be
greatly appreciated!

The important part of the wire log is below.  Names where changed to
protect the guilty but if that info's needed to look further into this,
I would be happy to provide it to someone directly.

Thanks in advance,
Ed

-- Wire Log --

2003/08/16 19:15:52:328 GMT-05:00 [DEBUG] wire - ->> "POST /login.asp
HTTP/1.1[\r][\n]"
2003/08/16 19:15:52:328 GMT-05:00 [DEBUG] wire - ->> "User-Agent:
Jakarta Commons-HttpClient/2.0rc1[\r][\n]"
2003/08/16 19:15:52:328 GMT-05:00 [DEBUG] wire - ->> "Host:
protecttheguilty.net[\r][\n]"
2003/08/16 19:15:52:328 GMT-05:00 [DEBUG] wire - ->> "Cookie:
ASPSESSIONIDCSSTSSDR=IFLECMCBDCJKEAFLIGEPAABE[\r][\n]"
2003/08/16 19:15:52:328 GMT-05:00 [DEBUG] wire - ->> "Content-Length:
51[\r][\n]"
2003/08/16 19:15:52:328 GMT-05:00 [DEBUG] wire - ->> "Content-Type:
application/x-www-form-urlencoded[\r][\n]"
2003/08/16 19:15:52:328 GMT-05:00 [DEBUG] wire - ->> "[\r][\n]"
2003/08/16 19:15:52:344 GMT-05:00 [DEBUG] wire - ->>
"OK=Enter+Premium+Members+Area&User=joeblow&PW=password"
2003/08/16 19:15:52:375 GMT-05:00 [DEBUG] wire - -<< "HTTP/1.1 100
Continue[\r][\n]"
2003/08/16 19:15:52:375 GMT-05:00 [DEBUG] wire - -<< "Server:
Microsoft-IIS/5.0[\r][\n]"
2003/08/16 19:15:52:375 GMT-05:00 [DEBUG] wire - -<< "Date: Sun, 17 Aug
2003 00:33:28 GMT[\r][\n]"
2003/08/16 19:15:52:375 GMT-05:00 [INFO] HttpMethodBase - -Discarding
unexpected response: HTTP/1.1 100 Continue
2003/08/16 19:15:54:062 GMT-05:00 [DEBUG] wire - -<< "HTTP/1.1 302
Object moved[\r][\n]"
2003/08/16 19:15:54:062 GMT-05:00 [DEBUG] wire - -<< "Server:
Microsoft-IIS/5.0[\r][\n]"
2003/08/16 19:15:54:062 GMT-05:00 [DEBUG] wire - -<< "Date: Sun, 17 Aug
2003 00:33:30 GMT[\r][\n]"
2003/08/16 19:15:54:062 GMT-05:00 [DEBUG] wire - -<< "Location:
redir.asp[\r][\n]"
2003/08/16 19:15:54:062 GMT-05:00 [DEBUG] wire - -<< "Content-Length:
121[\r][\n]"
2003/08/16 19:15:54:062 GMT-05:00 [DEBUG] wire - -<< "Content-Type:
text/html[\r][\n]"
2003/08/16 19:15:54:062 GMT-05:00 [DEBUG] wire - -<< "Cache-control:
private[\r][\n]"
2003/08/16 19:15:54:062 GMT-05:00 [INFO] HttpMethodBase - -Redirect
requested but followRedirects is disabled
Login form post: HTTP/1.1 302 Object moved
Logon cookies:
- ASPSESSIONIDCSSTSSDR=IFLECMCBDCJKEAFLIGEPAABE
2003/08/16 19:15:54:062 GMT-05:00 [DEBUG] wire - -<<
"<head><title>Object moved</title></head>[\n]"
2003/08/16 19:15:54:062 GMT-05:00 [DEBUG] wire - -<< "<body><h1>Object
Moved</h1>This object may be found <a HREF="">here</a>.</body>[\n]"
Redirect target: redir.asp
2003/08/16 19:15:54:109 GMT-05:00 [DEBUG] wire - ->> "GET redir.asp
HTTP/1.1[\r][\n]"
2003/08/16 19:15:54:109 GMT-05:00 [DEBUG] wire - ->> "User-Agent:
Jakarta Commons-HttpClient/2.0rc1[\r][\n]"
2003/08/16 19:15:54:109 GMT-05:00 [DEBUG] wire - ->> "Host:
protecttheguilty.net[\r][\n]"
2003/08/16 19:15:54:109 GMT-05:00 [DEBUG] wire - ->> "[\r][\n]"
Redirect: HTTP/1.1 400 Bad Request
2003/08/16 19:15:54:140 GMT-05:00 [DEBUG] wire - -<< "HTTP/1.1 400 Bad
Request[\r][\n]"
2003/08/16 19:15:54:156 GMT-05:00 [DEBUG] wire - -<< "Server:
Microsoft-IIS/5.0[\r][\n]"
2003/08/16 19:15:54:156 GMT-05:00 [DEBUG] wire - -<< "Date: Sun, 17 Aug
2003 00:33:30 GMT[\r][\n]"
2003/08/16 19:15:54:156 GMT-05:00 [DEBUG] wire - -<< "Connection:
close[\r][\n]"
2003/08/16 19:15:54:156 GMT-05:00 [DEBUG] wire - -<< "Content-Type:
text/html[\r][\n]"
2003/08/16 19:15:54:156 GMT-05:00 [DEBUG] wire - -<< "Content-Length:
87[\r][\n]"
2003/08/16 19:15:54:156 GMT-05:00 [DEBUG] wire - -<<
"<html><head><title>Error</title></head><body>The parameter is
incorrect. </body></html>"