You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Costin Manolache <cm...@yahoo.com> on 2002/12/12 04:29:21 UTC

[logging] Adding jndi java:env support

Based on Ceki's email - I think it would be a good idea to add
this mechanism in the default logging factory.

My proposal is to insert a lookup for
 
 java:comp/env/CommonsLoggingFactory

at the top of the discovery chain. If such a factory exists, it'll
be used to create the logger. If not, we'll continue with the
normal mechanism.

The big downsize is that we'll add a compile dependency on 
JNDI ( the code can catch ClassNotFound - and run even if 
JNDI is not present ). 

This will allow containers using commons-logging to better enforce
isolation between apps.

In addition, I think we should add an optional "domain name" prefix.
If such a prefix is set ( for example in java:comp/env/CommonsLoggingDomain)
then it'll be added in front of every log name that is created.

For example, if the container will set myHost:8080/myApp/ as a prefix,
 logs created in that app will be named:
  myHost:8080/myApp/org.apache.....


As a note, web.xml allows you to define and set a number of 
jndi entries. This could also be used to allow user-based tuning, 
but in general the container settings should be able to 
take preference . 

Costin




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


Re: [logging] Adding jndi java:env support

Posted by Costin Manolache <cm...@yahoo.com>.
Craig R. McClanahan wrote:

> 
> 
> On Wed, 11 Dec 2002, Costin Manolache wrote:
> 
>>
>> The big downsize is that we'll add a compile dependency on
>> JNDI ( the code can catch ClassNotFound - and run even if
>> JNDI is not present ).
>>
> 
> Why couldn't we use reflection to avoid the compile-time dependency as
> well?  After all, you like that pattern everywhere else :-).

That's not necesarily true - I usually like a hook that plugs a class
with the dependency, and conditional compilation. ( like in jdk11 compat
package in tomcat ). Since JNDI is included in JDK1.3 and available for 
1.1 - and it can be detected at runtime - I would rather use it directly
and keep the code simpler.

Costin



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


Re: [logging] Adding jndi java:env support

Posted by Ceki Gülcü <ce...@qos.ch>.
At 22:44 12.12.2002 -0800, you wrote:
>Craig R. McClanahan wrote:
>
> > I'm neutral on prefix versus suffix (although prefix feels a little more
> > in keeping with the hierarchical naming I tend to use for logging).  But
> > that raises an important consideration -- do the underlying logging
> > implementations we support deal gracefully with a ":" syntax in a logger
> > name?  In particlar, could I configure a logger for "DOMAIN:" and have it
> > apply to all loggers in that domain?  I'm wondering if we might want to
> > use a period (".") as the connector instead.
>
>I don't know - that's why I ask :-)
>
>We should certainly use a syntax that is compatible with both jdk1.4 and
>log4j. We could encode the name - but it needs to be easy to type ( I hate
>  %xx ).
>
>The only reason for suffix is easier configuration - but I'm not even sure
>it's easier :-)  Can log4j or jdk14 support
>   *.org.apache.commons.level=DEBUG  ?
>The use case of setting the log level on a component in multiple
>applications seems more common.

Why do you want to prefix (or postfix) logger names? What is the goal?
Is it security? If so, what do you do with the root logger? How can
you prevent a malevolent application from simply getting the logger it
wants by name?

>We can leave the log name unchanged and try to play
>some tricks with the logger config. Changing the log name seemed
>like the easiest solution.
>
>We can associate the application name with the hierarchy - but
>again I don't know how this would work from a config perspective.
>
>Ceki - any idea ?
>
>The use case I have in mind is a container ( like tomcat ), with
>several applications, a JMX-based config tool and some centralised
>config file ( eventually managed by the JMX tool or editor or some
>other UI ). The apps shouldn't have to do anything - they should just
>see the normal log patterns as a standalone app today.

Log4j 1.2 API has most of what you need. The only missing piece
is that logger repositories do not have names. If they had, you'd be
able to manage multiple repositories in JMX. You can configure each
logger repository separately (configurations act on logger
repositories). Oh, there is no support for multiple logger
repositories within a single configuration file but you can configure
multiple repositories with multiple config files.

Jacob Kjone has an implementation based on log4j 1.2.7 and for Tomcat
4.1.x.

See: http://marc.theaimsgroup.com/?l=log4j-dev&m=103725695000410&w=2

See also http://marc.theaimsgroup.com/?l=log4j-dev&m=103975966220495&w=2

>( of course - this should also work for jdk14 or other
>loggers - even if log4j is the best :-)

But of course! Would you like your miracle black or with sugar?  :-)

The things you want are so log4j specific that there is no way you can
successfully abstract them without reproducing/copying log4j. JCL
assumes that the important features of popular logging APIs can be
abstracted. My hereto experience shows that abstracting
independent APIs performing similar tasks is a major undertaking, much
more arduous than one would initially think.

I'd help more if I knew how.

>Costin

--
Ceki



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


Re: [logging] Adding jndi java:env support

Posted by Costin Manolache <cm...@yahoo.com>.
Craig R. McClanahan wrote:

> I'm neutral on prefix versus suffix (although prefix feels a little more
> in keeping with the hierarchical naming I tend to use for logging).  But
> that raises an important consideration -- do the underlying logging
> implementations we support deal gracefully with a ":" syntax in a logger
> name?  In particlar, could I configure a logger for "DOMAIN:" and have it
> apply to all loggers in that domain?  I'm wondering if we might want to
> use a period (".") as the connector instead.

I don't know - that's why I ask :-)

We should certainly use a syntax that is compatible with both jdk1.4 and
log4j. We could encode the name - but it needs to be easy to type ( I hate
 %xx ).

The only reason for suffix is easier configuration - but I'm not even sure 
it's easier :-)  Can log4j or jdk14 support 
  *.org.apache.commons.level=DEBUG  ?
The use case of setting the log level on a component in multiple 
applications seems more common.

We can leave the log name unchanged and try to play 
some tricks with the logger config. Changing the log name seemed
like the easiest solution.

We can associate the application name with the hierarchy - but
again I don't know how this would work from a config perspective.

Ceki - any idea ? 

The use case I have in mind is a container ( like tomcat ), with
several applications, a JMX-based config tool and some centralised
config file ( eventually managed by the JMX tool or editor or some
other UI ). The apps shouldn't have to do anything - they should just
see the normal log patterns as a standalone app today. 

( of course - this should also work for jdk14 or other 
loggers - even if log4j is the best :-)

Costin




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


Re: [logging] Adding jndi java:env support

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 12 Dec 2002, Costin Manolache wrote:

> Date: Thu, 12 Dec 2002 13:29:51 -0800
> From: Costin Manolache <cm...@yahoo.com>
> Reply-To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> To: commons-dev@jakarta.apache.org
> Subject: Re: [logging] Adding jndi java:env support
>
> The big issue is the behavior.
>
> My proposal was: if java:env/comp/LoggingDomain is set ( as a String ),
> it'll be used as a prefix in all loggers ( that don't have a prefix ).
> The syntax for the logger names will become:
>    DOMAIN:LOGGER
> And all loggers will have to be configured with this name ( if running
> in a container env with LoggingDomain support ).
>
> This is very important - and I would like to see more opinions. Maybe
> we should use the domain as a suffix instead of prefix ? Then you would
> have:
>   org.apache.foo:host:8080/examples
> as the log name, but you can set org.apache.foo.* to debug and enable
> the loggers in all apps.
>
> The prefix is cleaner, but the suffix may be easier to configure.
>
> For implementation - I'm in no hurry ( I would like to have it before
> tomcat5 is released - but that's not very close ). And I can use
> reflecion or a hook, if needed.
>

I'm neutral on prefix versus suffix (although prefix feels a little more
in keeping with the hierarchical naming I tend to use for logging).  But
that raises an important consideration -- do the underlying logging
implementations we support deal gracefully with a ":" syntax in a logger
name?  In particlar, could I configure a logger for "DOMAIN:" and have it
apply to all loggers in that domain?  I'm wondering if we might want to
use a period (".") as the connector instead.

>
> Costin

Craig


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


Re: [logging] Adding jndi java:env support

Posted by Costin Manolache <cm...@yahoo.com>.
The big issue is the behavior. 

My proposal was: if java:env/comp/LoggingDomain is set ( as a String ), 
it'll be used as a prefix in all loggers ( that don't have a prefix ).
The syntax for the logger names will become: 
   DOMAIN:LOGGER
And all loggers will have to be configured with this name ( if running
in a container env with LoggingDomain support ).

This is very important - and I would like to see more opinions. Maybe
we should use the domain as a suffix instead of prefix ? Then you would
have: 
  org.apache.foo:host:8080/examples
as the log name, but you can set org.apache.foo.* to debug and enable
the loggers in all apps.

The prefix is cleaner, but the suffix may be easier to configure.

For implementation - I'm in no hurry ( I would like to have it before
tomcat5 is released - but that's not very close ). And I can use 
reflecion or a hook, if needed.


Costin 

Richard Sitze wrote:

> I'll wait for the formal call to vote before I start voting, BUT I support
> the following:
> 
> +  release a 1.0.3 before any major code changes
> +  JNDI
> 
> -  NO API changes
> -  NO new runtime dependencies, and I'd like to be able to build, even if
> I cannot test it.
> 
> <ras>
> 
> *******************************************
> Richard A. Sitze
> 
> 
> 
> 
> sounds like a good plan.
> 
> this sounds (to me) like a change big enough to call for a new (major?)
> version.
> 
> (i'm not a cvs expert) but from what i can see there have been some small
> changes since the last release. maybe a quick bugfix 1.0.3 release would
> be a good idea before adding making this change.
> 
> - robert
> 
> On Thursday, December 12, 2002, at 03:29 AM, Costin Manolache wrote:
> 
>> Based on Ceki's email - I think it would be a good idea to add
>> this mechanism in the default logging factory.
>>
>> My proposal is to insert a lookup for
>>
>>  java:comp/env/CommonsLoggingFactory
>>
>> at the top of the discovery chain. If such a factory exists, it'll
>> be used to create the logger. If not, we'll continue with the
>> normal mechanism.
>>
>> The big downsize is that we'll add a compile dependency on
>> JNDI ( the code can catch ClassNotFound - and run even if
>> JNDI is not present ).
>>
>> This will allow containers using commons-logging to better enforce
>> isolation between apps.
>>
>> In addition, I think we should add an optional "domain name" prefix.
>> If such a prefix is set ( for example in
>> java:comp/env/CommonsLoggingDomain)
>> then it'll be added in front of every log name that is created.
>>
>> For example, if the container will set myHost:8080/myApp/ as a prefix,
>>  logs created in that app will be named:
>>   myHost:8080/myApp/org.apache.....
>>
>>
>> As a note, web.xml allows you to define and set a number of
>> jndi entries. This could also be used to allow user-based tuning,
>> but in general the container settings should be able to
>> take preference .
>>
>> Costin
>>
>>
>>
>>
>> --
>> To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache
> .
>> org>
>> For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache
> .
>> org>
>>
> 
> 
> --
> To unsubscribe, e-mail:   <
> mailto:commons-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <
> mailto:commons-dev-help@jakarta.apache.org>




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


Re: [logging] Adding jndi java:env support

Posted by Richard Sitze <rs...@us.ibm.com>.
I'll wait for the formal call to vote before I start voting, BUT I support 
the following:

+  release a 1.0.3 before any major code changes
+  JNDI

-  NO API changes
-  NO new runtime dependencies, and I'd like to be able to build, even if 
I cannot test it.

<ras>

*******************************************
Richard A. Sitze




sounds like a good plan.

this sounds (to me) like a change big enough to call for a new (major?) 
version.

(i'm not a cvs expert) but from what i can see there have been some small 
changes since the last release. maybe a quick bugfix 1.0.3 release would 
be a good idea before adding making this change.

- robert

On Thursday, December 12, 2002, at 03:29 AM, Costin Manolache wrote:

> Based on Ceki's email - I think it would be a good idea to add
> this mechanism in the default logging factory.
>
> My proposal is to insert a lookup for
>
>  java:comp/env/CommonsLoggingFactory
>
> at the top of the discovery chain. If such a factory exists, it'll
> be used to create the logger. If not, we'll continue with the
> normal mechanism.
>
> The big downsize is that we'll add a compile dependency on
> JNDI ( the code can catch ClassNotFound - and run even if
> JNDI is not present ).
>
> This will allow containers using commons-logging to better enforce
> isolation between apps.
>
> In addition, I think we should add an optional "domain name" prefix.
> If such a prefix is set ( for example in 
> java:comp/env/CommonsLoggingDomain)
> then it'll be added in front of every log name that is created.
>
> For example, if the container will set myHost:8080/myApp/ as a prefix,
>  logs created in that app will be named:
>   myHost:8080/myApp/org.apache.....
>
>
> As a note, web.xml allows you to define and set a number of
> jndi entries. This could also be used to allow user-based tuning,
> but in general the container settings should be able to
> take preference .
>
> Costin
>
>
>
>
> --
> To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache
.
> org>
> For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache
.
> org>
>


--
To unsubscribe, e-mail:   <
mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <
mailto:commons-dev-help@jakarta.apache.org>



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


Re: [logging] Adding jndi java:env support

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
sounds like a good plan.

this sounds (to me) like a change big enough to call for a new (major?) 
version.

(i'm not a cvs expert) but from what i can see there have been some small 
changes since the last release. maybe a quick bugfix 1.0.3 release would 
be a good idea before adding making this change.

- robert

On Thursday, December 12, 2002, at 03:29 AM, Costin Manolache wrote:

> Based on Ceki's email - I think it would be a good idea to add
> this mechanism in the default logging factory.
>
> My proposal is to insert a lookup for
>
>  java:comp/env/CommonsLoggingFactory
>
> at the top of the discovery chain. If such a factory exists, it'll
> be used to create the logger. If not, we'll continue with the
> normal mechanism.
>
> The big downsize is that we'll add a compile dependency on
> JNDI ( the code can catch ClassNotFound - and run even if
> JNDI is not present ).
>
> This will allow containers using commons-logging to better enforce
> isolation between apps.
>
> In addition, I think we should add an optional "domain name" prefix.
> If such a prefix is set ( for example in 
> java:comp/env/CommonsLoggingDomain)
> then it'll be added in front of every log name that is created.
>
> For example, if the container will set myHost:8080/myApp/ as a prefix,
>  logs created in that app will be named:
>   myHost:8080/myApp/org.apache.....
>
>
> As a note, web.xml allows you to define and set a number of
> jndi entries. This could also be used to allow user-based tuning,
> but in general the container settings should be able to
> take preference .
>
> Costin
>
>
>
>
> --
> To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.
> org>
> For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.
> org>
>


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


Re: [logging] Adding jndi java:env support

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 11 Dec 2002, Costin Manolache wrote:

>
> The big downsize is that we'll add a compile dependency on
> JNDI ( the code can catch ClassNotFound - and run even if
> JNDI is not present ).
>

Why couldn't we use reflection to avoid the compile-time dependency as
well?  After all, you like that pattern everywhere else :-).


Craig


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