Re: getConfigurationFileName()

2003-09-29 Thread Scott Morgan
Hi Henrik,

  Try;

   DOMConfigurator.configureAndWatch(YourClass.class.getResource(xml/log4j.xml));
for log4j.xml
Or
   PropertyConfigurator.configureAndWatch(YourPropertyFile);
for log4j.properties


 Is there a way that I can get the filename and absolute path for the
 file used to configure log4j. Once I am up and running, I would like to
 be able to check that I am indeed using the right configuration file.



 - To
 unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


-- 
Scott Morgan
President Adligo Inc.
Ph:  773-758-8735
Fax: 773-632-0568
http://www.adligo.com



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Questions on initial log4j instance

2003-09-29 Thread Yu Xiang Xi (Maveo)
I have seen different usage of initial log4j instance like below
private final static Logger logger = Logger.getLogger(some.name);
and
private final transient static Logger logger =
Logger.getLogger(some.name);
the second one has a additional keyword transient.

Which way is recommended?
Thanks in advance.

Best Regards
Xi Yuxiang
Maveo Systems Limited

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



reconfigure an already configured log4j

2003-09-29 Thread Michael Erskine
Firstly, allow me to apologise if this question has already been
answered - I don't have access to a searchable archive of the list.

I am using log4j within the OpenEJB EJB server and I am able to set my
configuration file (via the property
-Dlog4j.configuration=file:conf/logging.conf) add appenders, loggers
etc. 

This all works perfectly but I now dearly need to reconfigure the
loggers at runtime and I have found that in previous projects a
PropertyConfigurator.configureAndWatch will do the trick even if log4j
is already configured (in classes beyond my control).


* QUESTION 1: Is it OK to reconfigure log4j in this way ?


This technique isn't working under OpenEJB because log4j can't find the
config file a second time around when configured with the same URL
'file:conf/logging.conf' OR with a URL to the absolute file path
'file:///C|/openejb-0.8.3/conf/logging.conf'. Switching on -Dlog4j.debug
gives me...

log4j: [file:///C|/openejb-0.8.3/conf/logging.conf] does not exist. 

I vaguely understand that the EJB container may have a different class
loader or context although I don't believe this to be the case with
version 0.8.3 OpenEJB.


* QUESTION 2: Why doesn't log4j like my config file URLs? 
They look logical to me :) - are they broken?


Thanks for enduring my queries :),

Michael.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: bad days and good days

2003-09-29 Thread Shapira, Yoav

Howdy,

I spent most of the day, going over the documentation on log4j and
various
ways of logging under Tomcat. Great article on commons-logging vs.
Log4j :)
I saw a reference to how different web-applications can have different
log4j
configurations in think again, but I am not sure where that is supposed
to
be described. I have yet to see any explanation of how that is
supported.

Simple:
1. Put log4j.jar in each webapp's WEB-INF/lib directory, and no where
else.
2. Put log4j.properties in each webapp's WEB-INF/classes directory, and
no where else.

That's it.

You can also doing it programmatically by writing an init servlet or
servlet context listener that configure log4j.  Then you can put the
log4j.properties file anywhere under your webapp's root directory, and
use ServletContext#getResourceAsStream(...) to get the file and feed it
to PropertyConfigurator.

Yoav Shapira



This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: getConfigurationFileName()

2003-09-29 Thread Shapira, Yoav

Howdy,
If you used a classpath-discovery-based mechanism for configuring log4j,
you can do this:
http://javaalmanac.com/egs/java.lang/ClassOrigin.html?l=rel to figure
out if it came from a jar and if so which jar.  But that's a partial
solution at best ;(

Yoav Shapira
Millennium ChemInformatics


-Original Message-
From: Henrik Vendelbo [mailto:[EMAIL PROTECTED]
Sent: Saturday, September 27, 2003 9:31 PM
To: [EMAIL PROTECTED]
Subject: getConfigurationFileName()

Is there a way that I can get the filename and absolute path for the
file
used to configure log4j. Once I am up and running, I would like to be
able
to check that I am indeed using the right configuration file.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: different files

2003-09-29 Thread Alan Roberto Romaniuc
Ceki Gülcü wrote:

Alan,

Have you tried putting log4j.jar in a directory accessible to the 
common loader?

At 01:07 PM 9/26/2003 -0300, Alan Roberto Romaniuc wrote:

Hi,



Yep, I did it 

  A, B, L are in the same webapp the problem is that I am not 
able to log thing from library in the same log of library caller class



   I have a library L which uses log4j.
   I have a application A, which uses L and log4j,
   I have a application B, which uses L and log4j too.
   A and B runs together (inside tomcat...),
I am able to do differents logs, A.log(A),B.log (B) and L.log (L) 
, but I would like to log
  L in B.log, when B calls it, and L in A.log when A calls it.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: reconfigure an already configured log4j

2003-09-29 Thread Michael Erskine
 
 * QUESTION 2: Why doesn't log4j like my config file URLs? 
 They look logical to me :) - are they broken?
 

I've solved this one -- all I needed to do is pass the filename rather
than a URL (I can't remember why on earth I thought I had to pass a URL
:)

Michael.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Questions on initial log4j instance

2003-09-29 Thread Cakalic, James
Agree -- private static final Logger is what I recommend. Modifiers are
static then final, not vice versa. JLS section 8.3.1 defines the
production

FieldModifier: one of
public protected private
static final transient volatile

and states, If two or more (distinct) field modifiers appear in a field
declaration, it is customary, though not required, that they appear in
the order consistent with that shown above in the production for
FieldModifier.

WRT to serialization, declaring a field both static and transient is
redundant as static fields are not serialized by definition.

Jim

-Original Message-
From: Shapira, Yoav [mailto:[EMAIL PROTECTED]
Sent: Monday, September 29, 2003 7:55 AM
To: Log4J Users List
Subject: RE: Questions on initial log4j instance



Howdy,
Where did you see the transient one?

The perfect syntax depends on your usage of the Logger.  The most common
one I think, as well as the one most frequently illustrated in the log4j
documentation, is private final static (which should be private static
final according to JLS recommendations ;))

Yoav Shapira
Millennium ChemInformatics


-Original Message-
From: Yu Xiang Xi (Maveo) [mailto:[EMAIL PROTECTED]
Sent: Monday, September 29, 2003 4:58 AM
To: 'Log4J Users List'
Subject: Questions on initial log4j instance

I have seen different usage of initial log4j instance like below
private final static Logger logger = Logger.getLogger(some.name);
   and
private final transient static Logger logger =
Logger.getLogger(some.name);
the second one has a additional keyword transient.

Which way is recommended?
Thanks in advance.

Best Regards
Xi Yuxiang
Maveo Systems Limited

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




This e-mail, including any attachments, is a confidential business
communication, and may contain information that is confidential,
proprietary and/or privileged.  This e-mail is intended only for the
individual(s) to whom it is addressed, and may not be saved, copied,
printed, disclosed or used by anyone else.  If you are not the(an)
intended recipient, please immediately delete this e-mail from your
computer system and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Confidentiality Warning:  This e-mail contains information intended only for the use 
of the individual or entity named above.  If the reader of this e-mail is not the 
intended recipient or the employee or agent responsible for delivering it to the 
intended recipient, any dissemination, publication or copying of this e-mail is 
strictly prohibited. The sender does not accept any responsibility for any loss, 
disruption or damage to your data or computer system that may occur while using data 
contained in, or transmitted with, this e-mail.   If you have received this e-mail in 
error, please immediately notify us by return e-mail.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Questions on initial log4j instance

2003-09-29 Thread Ceki Gülcü
At 04:58 PM 9/29/2003 +0800, Yu Xiang Xi  (Maveo) wrote:
I have seen different usage of initial log4j instance like below
private final static Logger logger = Logger.getLogger(some.name);
looks good.

and
private final transient static Logger logger =
Logger.getLogger(some.name);
the second one has a additional keyword transient.
Loggers cannot be serialized so marking them transient can be useful for 
non static loggers.

However, since static variables are not serialized, there is no need to 
mark them as transient.

Moreover, in addition to serialization aspects, the keyword 'transient' has 
other meanings. It forces the JVM to re-reread the value of the variable 
from memory for each access, adding unnecessary overhead.

Which way is recommended?
The recommended form is:

  private static final Logger logger = ...


Thanks in advance.

Best Regards
Xi Yuxiang
Maveo Systems Limited
--
Ceki Gülcü
 For log4j documentation consider The complete log4j manual
 ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp
 import org.apache.Facetime;
 ApacheCon US 2003, 18-21 November http://apachecon.com/


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Questions on initial log4j instance

2003-09-29 Thread Shapira, Yoav

Howdy,
I hate to be such a nitpick on this, and it's a matter of style only not substance, 
but in case you care, things that are static final should be capitalized, so if you 
have a private static final Logger it should be
private static final Logger LOGGER = Logger.getLogger(some.name);

If you leave it as logger (lower case), obviously it still works fine but tools like 
Checkstyle complain.

Yoav Shapira
Millennium ChemInformatics


-Original Message-
From: Ceki Gülcü [mailto:[EMAIL PROTECTED]
Sent: Monday, September 29, 2003 11:41 AM
To: Log4J Users List
Subject: Re: Questions on initial log4j instance

At 04:58 PM 9/29/2003 +0800, Yu Xiang Xi  (Maveo) wrote:
I have seen different usage of initial log4j instance like below
private final static Logger logger = Logger.getLogger(some.name);

looks good.

 and
private final transient static Logger logger =
Logger.getLogger(some.name);
the second one has a additional keyword transient.

Loggers cannot be serialized so marking them transient can be useful for
non static loggers.

However, since static variables are not serialized, there is no need to
mark them as transient.

Moreover, in addition to serialization aspects, the keyword 'transient' has
other meanings. It forces the JVM to re-reread the value of the variable
from memory for each access, adding unnecessary overhead.

Which way is recommended?

The recommended form is:

   private static final Logger logger = ...


Thanks in advance.

Best Regards
Xi Yuxiang
Maveo Systems Limited

--
Ceki Gülcü

  For log4j documentation consider The complete log4j manual
  ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp

  import org.apache.Facetime;
  ApacheCon US 2003, 18-21 November http://apachecon.com/



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Questions on initial log4j instance

2003-09-29 Thread Kevin Klinemeier
Do you mean 'volatile' here?  I can't find in the JLS where transient
has this affect.  It wouldn't be the first time I've looked for
something in the JLS and not found it, though.

-Kevin

--- Ceki Gülcü [EMAIL PROTECTED] wrote:
 Moreover, in addition to serialization aspects, the keyword
 'transient' has 
 other meanings. It forces the JVM to re-reread the value of the
 variable 
 from memory for each access, adding unnecessary overhead.



__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Questions on initial log4j instance

2003-09-29 Thread Ceki Gülcü
Yes, of course 'volatile' not 'transient'.

I somehow merged volatile and transient in my mind.

At 09:50 AM 9/29/2003 -0700, Kevin Klinemeier wrote:
Do you mean 'volatile' here?  I can't find in the JLS where transient
has this affect.  It wouldn't be the first time I've looked for
something in the JLS and not found it, though.
-Kevin

--- Ceki Gülcü [EMAIL PROTECTED] wrote:
 Moreover, in addition to serialization aspects, the keyword
 'transient' has
 other meanings. It forces the JVM to re-reread the value of the
 variable
 from memory for each access, adding unnecessary overhead.
--
Ceki Gülcü
 For log4j documentation consider The complete log4j manual
 ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp
 import org.apache.Facetime;
 ApacheCon US 2003, 18-21 November http://apachecon.com/


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]