You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Eddie Post <po...@hotmail.com> on 2001/09/03 14:28:53 UTC

separate log files ??

Hellu,
I already posted about the same question two weeks ago, hope to get some
advice this time.

The problem I am having is the following:
- I am using a J2EE application server, called Orion to run my application
and use log4j to log.
This works fine, except that is very hard to tell Orion which log4j-core.jar
and log4j.jar it has to use.
That is: I included in every J2EE application a log4j-core and log4j.jar,
just like the spec tell.

However, when application A logs in log file log_file_A and it connects to
applicatoin B, it continues logging in log_file_B. This comes because
application B initializes log4j with PropertyConfigurator.configure(config
file) and appearantly it overrides the log4j properties of application A.

I am now looking how I should overcome this and was thinking about the
following:
- explictely tell the classloader which jar file it should use. I have no
idea yet how to do that. I don't even think this is a good solution as I
loading class files in my Application A and I want that the loaded calsses
have their own log file.
- simple use one log4j config file and add a appender for every log file.
However I don't know how to assign a appender to a category ??. I was
thinking about something like:
---
log4j.category.nl.unwired.sgs.web=DEBUG, FILE
----
, where FILE is an appender, but this doesn't work. This would be a very
flexible-good solution for me.. too bad... Hmmmm

Please some help on the following:
- How have others solved this problem ?
- Where can I find the correct syntax of the properties that can be set in
the log4j property file ? and what are all those properties ?

Eddie


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


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


Re: separate log files ??

Posted by Mitchell Ackermann <mi...@epsiia.com>.
I believe what he meant was something like this:
http://jakarta.apache.org/log4j/docs/FAQ.html#namingCategories
http://jakarta.apache.org/log4j/docs/FAQ.html#className

Mitchell Ackermann

----- Original Message ----- 
From: Eddie <po...@hotmail.com>
To: LOG4J Users Mailing List <lo...@jakarta.apache.org>
Sent: Tuesday, September 04, 2001 5:39 AM
Subject: Re: separate log files ??


Paul,

I noticed that I wasn't very specific.
What I don't understand is what you mean by
"use classname as category name and it doesn't matter what order things are
configured"
as you said in your mail ?

Eddie

> ----- Original Message -----
> From: "Paul Glezen" <pg...@atdial.net>
> To: "LOG4J Users Mailing List" <lo...@jakarta.apache.org>
> Sent: Monday, September 03, 2001 9:24 PM
> Subject: Re: separate log files ??
>
> > Sounds like a judicious use of categories could solve this.  If the set
> > of classes that make up application A and B are disjoint, then it is
> > trivial: use classname as category name and it doesn't matter what order
> > things are configured.  Set log_file_A for the app_A categories and
> > log_file_B for the app_B categories.
> >
> > If you have utility classes used in both app_A and app_B, then you need
> > for the utility class to come up with a scheme (perhaps by using some
> > kind of context information) to uniquely name the category instance that
> > each utility class instance uses.
> >
> > If you're calling static methods of utility classes, then you may be out
> > of luck.
> >
> > - Paul



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


Re: separate log files ??

Posted by Eddie <po...@hotmail.com>.
Paul,

I noticed that I wasn't very specific.
What I don't understand is what you mean by
"use classname as category name and it doesn't matter what order things are
configured"
as you said in your mail ?

Eddie

----- Original Message -----
From: "Eddie" <po...@hotmail.com>
To: "LOG4J Users Mailing List" <lo...@jakarta.apache.org>
Sent: Monday, September 03, 2001 11:56 PM
Subject: Re: separate log files ??


> Paul,
>
> Thanks Paul, but you are going a bit too fast for me.
> Could you please use some more words, as don't completely understand what
> you mean (do you have a tiny example).
>
> Eddie
>
> ----- Original Message -----
> From: "Paul Glezen" <pg...@atdial.net>
> To: "LOG4J Users Mailing List" <lo...@jakarta.apache.org>
> Sent: Monday, September 03, 2001 9:24 PM
> Subject: Re: separate log files ??
>
>
> > Eddie Post wrote:
> > >
> > > However, when application A logs in log file log_file_A and it
connects
> to
> > > applicatoin B, it continues logging in log_file_B. This comes because
> > > application B initializes log4j with
> PropertyConfigurator.configure(config
> > > file) and appearantly it overrides the log4j properties of application
> A.
> > >
> >
> > Eddie,
> >
> > Sounds like a judicious use of categories could solve this.  If the set
> > of classes that make up application A and B are disjoint, then it is
> > trivial: use classname as category name and it doesn't matter what order
> > things are configured.  Set log_file_A for the app_A categories and
> > log_file_B for the app_B categories.
> >
> > If you have utility classes used in both app_A and app_B, then you need
> > for the utility class to come up with a scheme (perhaps by using some
> > kind of context information) to uniquely name the category instance that
> > each utility class instance uses.
> >
> > If you're calling static methods of utility classes, then you may be out
> > of luck.
> >
> > - Paul
> > --
> > Beware of bugs in the above code.  I have
> > only proved it correct, not tried it.
> > -Don Knuth
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: log4j-user-help@jakarta.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>
>

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


Re: separate log files ??

Posted by Eddie <po...@hotmail.com>.
Paul,

Thanks Paul, but you are going a bit too fast for me.
Could you please use some more words, as don't completely understand what
you mean (do you have a tiny example).

Eddie

----- Original Message -----
From: "Paul Glezen" <pg...@atdial.net>
To: "LOG4J Users Mailing List" <lo...@jakarta.apache.org>
Sent: Monday, September 03, 2001 9:24 PM
Subject: Re: separate log files ??


> Eddie Post wrote:
> >
> > However, when application A logs in log file log_file_A and it connects
to
> > applicatoin B, it continues logging in log_file_B. This comes because
> > application B initializes log4j with
PropertyConfigurator.configure(config
> > file) and appearantly it overrides the log4j properties of application
A.
> >
>
> Eddie,
>
> Sounds like a judicious use of categories could solve this.  If the set
> of classes that make up application A and B are disjoint, then it is
> trivial: use classname as category name and it doesn't matter what order
> things are configured.  Set log_file_A for the app_A categories and
> log_file_B for the app_B categories.
>
> If you have utility classes used in both app_A and app_B, then you need
> for the utility class to come up with a scheme (perhaps by using some
> kind of context information) to uniquely name the category instance that
> each utility class instance uses.
>
> If you're calling static methods of utility classes, then you may be out
> of luck.
>
> - Paul
> --
> Beware of bugs in the above code.  I have
> only proved it correct, not tried it.
> -Don Knuth
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>
>

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


Re: separate log files ??

Posted by Paul Glezen <pg...@atdial.net>.
Eddie Post wrote:
> 
> However, when application A logs in log file log_file_A and it connects to
> applicatoin B, it continues logging in log_file_B. This comes because
> application B initializes log4j with PropertyConfigurator.configure(config
> file) and appearantly it overrides the log4j properties of application A.
> 

Eddie,

Sounds like a judicious use of categories could solve this.  If the set
of classes that make up application A and B are disjoint, then it is
trivial: use classname as category name and it doesn't matter what order
things are configured.  Set log_file_A for the app_A categories and
log_file_B for the app_B categories.

If you have utility classes used in both app_A and app_B, then you need
for the utility class to come up with a scheme (perhaps by using some
kind of context information) to uniquely name the category instance that
each utility class instance uses.

If you're calling static methods of utility classes, then you may be out
of luck.

- Paul
-- 
Beware of bugs in the above code.  I have
only proved it correct, not tried it.
-Don Knuth

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