Re: Forcing XML configuration file to reset Log4J configuration

2007-11-13 Thread Curt Arnold


On Nov 13, 2007, at 3:58 PM, Paul Duffy wrote:


Folks,

Been bit by the incremental nature of XML configuration  
application.  Is there any way to not apply a changed XML  
configuration incrementally, but instead force full reset to  
reflect the state of the configuration file?


Cheers



log4j 1.2.15 and later support a reset attribute on the  
log4j:configuration element:




See http://issues.apache.org/bugzilla/show_bug.cgi?id=17531


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



Re: Forcing XML configuration file to reset Log4J configuration

2007-11-13 Thread Paul Duffy

Thanks Matthew.

We're talking about a JBoss environment using the configureAndWatch type 
of mechanism to pick up the XML configuration changes.


There is no way to fully reset and reload the configuration w/o 
restarting the logging service?



Matthew Kemp wrote:

To reset an entire configuration you need something like this:

public void reloadLog4J() {
LogManager.resetConfiguration();
DOMConfigurator.configure("log4j.xml");
}

Unfortunately, even the DOMConfigurator.configureAndWatch() only does 
an incremental reload.



Matt


On Nov 13, 2007 3:58 PM, Paul Duffy <[EMAIL PROTECTED] 
> wrote:


Folks,

Been bit by the incremental nature of XML configuration
application.  Is
there any way to not apply a changed XML configuration incrementally,
but instead force full reset to reflect the state of the
configuration file?

Cheers

-
To unsubscribe, e-mail: [EMAIL PROTECTED]

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





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



Re: Forcing XML configuration file to reset Log4J configuration

2007-11-13 Thread Matthew Kemp
To reset an entire configuration you need something like this:

public void reloadLog4J() {
LogManager.resetConfiguration();
DOMConfigurator.configure("log4j.xml");
}

Unfortunately, even the DOMConfigurator.configureAndWatch() only does an
incremental reload.


Matt


On Nov 13, 2007 3:58 PM, Paul Duffy <[EMAIL PROTECTED]> wrote:

> Folks,
>
> Been bit by the incremental nature of XML configuration application.  Is
> there any way to not apply a changed XML configuration incrementally,
> but instead force full reset to reflect the state of the configuration
> file?
>
> Cheers
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Forcing XML configuration file to reset Log4J configuration

2007-11-13 Thread Paul Duffy

Folks,

Been bit by the incremental nature of XML configuration application.  Is 
there any way to not apply a changed XML configuration incrementally, 
but instead force full reset to reflect the state of the configuration file?


Cheers

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



RE: file location - windows vista

2007-11-13 Thread epic winter

Thanks you guys I got it.

> From: [EMAIL PROTECTED]
> Subject: Re: file location - windows vista
> Date: Tue, 13 Nov 2007 11:47:11 -0600
> To: log4j-user@logging.apache.org
> 
> 
> On Nov 13, 2007, at 9:55 AM, James A. N. Stauffer wrote:
> 
> > With an XML config you can access system properties like ${user.home$
> > }/logfilename.log
> >
> 
> 
> I don't think the trailing $ is necessary and would expect that would  
> actually break things, but I'm not sure.  System property  
> substitution also works with the property configurator.  See the JDK  
> documentation for System.getProperties() (http://java.sun.com/javase/ 
> 6/docs/api/java/lang/System.html#getProperties()) for a list of  
> always available system properties.   Using ${java.io.tmpdir} would  
> also be an option.
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

_
Windows Live Hotmail and Microsoft Office Outlook – together at last.  Get it 
now.
http://office.microsoft.com/en-us/outlook/HA102225181033.aspx?pid=CL100626971033

Re: file location - windows vista

2007-11-13 Thread James A. N. Stauffer
That was a typo on my part.  It should have been ${user.home
}/logfilename.log

On Nov 13, 2007 11:47 AM, Curt Arnold <[EMAIL PROTECTED]> wrote:

>
> On Nov 13, 2007, at 9:55 AM, James A. N. Stauffer wrote:
>
> > With an XML config you can access system properties like ${user.home$
> > }/logfilename.log
> >
>
>
> I don't think the trailing $ is necessary and would expect that would
> actually break things, but I'm not sure.  System property
> substitution also works with the property configurator.  See the JDK
> documentation for System.getProperties() (http://java.sun.com/javase/
> 6/docs/api/java/lang/System.html#getProperties()) for a list of
> always available system properties.   Using ${java.io.tmpdir} would
> also be an option.
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
James A. N. Staufferhttp://www.geocities.com/stauffer_james/
Are you good? Take the test at http://www.livingwaters.com/good/


Re: file location - windows vista

2007-11-13 Thread Curt Arnold


On Nov 13, 2007, at 9:55 AM, James A. N. Stauffer wrote:


With an XML config you can access system properties like ${user.home$
}/logfilename.log




I don't think the trailing $ is necessary and would expect that would  
actually break things, but I'm not sure.  System property  
substitution also works with the property configurator.  See the JDK  
documentation for System.getProperties() (http://java.sun.com/javase/ 
6/docs/api/java/lang/System.html#getProperties()) for a list of  
always available system properties.   Using ${java.io.tmpdir} would  
also be an option.



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



Re: Log4j for Multiple classes

2007-11-13 Thread Curt Arnold


On Nov 13, 2007, at 8:47 AM, Tursun Wali wrote:


Dear all,

I want to write a logger for my project . log file for single class is
Ok . log for  multiple classes seems problem to me .  I do not want to
allocate  one logger for one class , 10 logger for 10 class. I want to
some other smart way .
There was a post in mailing list by John  ([EMAIL PROTECTED]
) . tile is   "How to use Log4J in Multiple
classes? App Design? Date Tue, 12 Jul 2005 23:57:43
GMT



The number of loggers used in an application does not bear a direct  
correspondence to the number of "log files" produced by the  
application.   Number of loggers do not necessarily have a  
correspondence to the number of classes in an application, however  
the most common usage pattern is to associate distinct loggers for  
each class.


Think of loggers as a topic of conversation or a channel on an audio  
mixing board (like mic 1 or instrument 7).  The configuration  
determines what topics are followed and where they are eventually  
output.  Using one logger is like having an entire band standing  
around one microphone, you can turn the volume up or down on  
everybody, but you can't adjust the volume of individual performers.   
Having many loggers is like having many microphones where you can  
adjust the volume, mute the channel or record the performers separately.


appenders (your "log files") are like recording devices attached to a  
mixing board.  You could mix all the channels down to a one-channel  
recorder, record each channel independently or many intermediate  
combinations.


Each individual logger in a hierarchy (like a channel in a mixer) is  
cheap to construct.   It is a very common usage pattern even in large  
applications to have an individual logger per class and has not been  
an issue.


If you really want to only have "one logger", just change the  
initialization of the logger instances from:


public class MyClass {
private static Logger logger = Logger.getLogger(MyClass.class);

to

public class MyClass {
private static Logger logger = Logger.getRootLogger();


However, I see that as an unwise optimization, since you lose the  
ability to independently control the logging of MyClass.


Until you have something more specific clearly in mind, attach a  
single FileAppender to the root logger (effectively mixing all the  
channels down to one recording) using a configuration file.  That  
would allow you to get more creative in your mixing later without  
modifying your application.


Hope this discussion clears up a few things and rereading the  
documentation makes things clearer.


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



Re: Trouble Referencing An XML Config File

2007-11-13 Thread tom . x . purl
Thanks for the quick response Matthew!

"Matthew Kemp" <[EMAIL PROTECTED]> wrote on 11/08/2007 04:35:21 PM:

> PropertyConfigurator only reads property files. To read an xml config
> you need to use the DOMConfigurator. Another option would allow log4j
> to statically initialize itself (your config file needs to be on the
> class path).

Thanks for this.  I couldn't find this information anywhere.

Also, I found that I don't have to use a XML config file to send all log
messages to STDERR.  Here's the config file that ended up working for
me:

log4j.rootLogger=DEBUG, stderr

log4j.appender.stderr=org.apache.log4j.ConsoleAppender
log4j.appender.stderr.layout=org.apache.log4j.PatternLayout
log4j.appender.stderr.layout.ConversionPattern=%-4r [%t] %-5p %c %x - 
%m%n
log4j.appender.stderr.Target=System.err
  ^

Thanks again!

Tom Purl

-
This communication is for informational purposes only. It is not
intended as an offer or solicitation for the purchase or sale of
any financial instrument or as an official confirmation of any
transaction. All market prices, data and other information are not
warranted as to completeness or accuracy and are subject to change
without notice. Any comments or statements made herein do not
necessarily reflect those of JPMorgan Chase & Co., its subsidiaries
and affiliates.

This transmission may contain information that is privileged,
confidential, legally privileged, and/or exempt from disclosure
under applicable law. If you are not the intended recipient, you
are hereby notified that any disclosure, copying, distribution, or
use of the information contained herein (including any reliance
thereon) is STRICTLY PROHIBITED. Although this transmission and any
attachments are believed to be free of any virus or other defect
that might affect any computer system into which it is received and
opened, it is the responsibility of the recipient to ensure that it
is virus free and no responsibility is accepted by JPMorgan Chase &
Co., its subsidiaries and affiliates, as applicable, for any loss
or damage arising in any way from its use. If you received this
transmission in error, please immediately contact the sender and
destroy the material in its entirety, whether in electronic or hard
copy format. Thank you.

Please refer to http://www.jpmorgan.com/pages/disclosures for
disclosures relating to UK legal entities.

Re: file location - windows vista

2007-11-13 Thread James A. N. Stauffer
With an XML config you can access system properties like ${user.home$
}/logfilename.log

On Nov 12, 2007 2:42 PM, epic winter <[EMAIL PROTECTED]> wrote:

>
> I have an application using log4j and in the past I have just specified:
> log4j.appender.file.File=logfilename.log
>
> This would create the file in the location where the java app was
> launched.  This was in C:\program files\MyApp\logfilename.log
>
> But windows vista doesn't seem to allow my program to write anywhere in
> c:\program files.  I assume that log file is not being written at all now
> because of these permissions.  Correct?
>
> I guess my solution is to write the log file to a folder in the user's
> home directory.  Is there a way to auto specify the user's home directory
> without hard coding it?
>
> thanks
> -ryan
>
> _
> Help yourself to FREE treats served up daily at the Messenger Café. Stop
> by today.
>
> http://www.cafemessenger.com/info/info_sweetstuff2.html?ocid=TXT_TAGLM_OctWLtagline




-- 
James A. N. Staufferhttp://www.geocities.com/stauffer_james/
Are you good? Take the test at http://www.livingwaters.com/good/


Re: Log4j for Multiple classes

2007-11-13 Thread Matthew Kemp
Loggers can be named anything you want them to be. Traditionally they're
named after the class to aid with debugging, etc. You don't have to
specifically create a logger for each class. If at the top of every class
you had a line like -

private static final Logger logger = Logger.getLogger("foo");

- then all your classes would share the logger "foo". As far as writing to a
file goes, appenders like FileAppender and DailyRollingFileAppender are what
actually create/write to files. There is a many to many relationship between
loggers and appenders. One logger might have many appenders or on appender
might be attached to many loggers.

If all you want is to have all classes log to the same file I'd stick with
the per class logger and setup a logger that is "com.foo" where com.foo is
the basis of your package hierarchy. Then attach your file appender to that
logger and all classes under com.foo will write to the file.

Hope that helps.

Matt



On Nov 13, 2007 8:47 AM, Tursun Wali <[EMAIL PROTECTED]> wrote:

> Dear all,
>
> I want to write a logger for my project . log file for single class is
> Ok . log for  multiple classes seems problem to me .  I do not want to
> allocate  one logger for one class , 10 logger for 10 class. I want to
> some other smart way .
> There was a post in mailing list by John  ([EMAIL PROTECTED]
> ) . tile is   "How to use Log4J in Multiple
> classes? App Design? Date Tue, 12 Jul 2005 23:57:43
> GMT
>
>  John Hurt wrote:
> >
> > > Hi,
> > >
> > > My application is split up into multiple classes. If I had
> > > processing in
> > > each class that I wanted to log, what's the best way to make a
> > > reference to
> > > the Logger available, so that for instance they all write to the
> > > same log
> > > file?
> > >
> > > Do I create an instance of the Logger class at the beginning of the
> > > program
> > > flow, then pass that class to all the methods/classes that plan to do
> > > logging?
> > >
> > > Do I make a wrapper singleton class that has a Logger in it and all
> > > code
> > > refers to the wrapper class?
> > >
> > > Do I use a base class (or interface or abstract class) that includes a
> > > reference to a Logger class?
> > >
> > > Anyone has generic examples where Logger is used in more than 1
> > > class, how
> > > to use it gracefully? Thanks.
> ".
> that is exactly what I want . but I could not contact with him . that
> email address is not working .
> Could you please one if you give me good advice !!!
>
> Best Regards
> Tom
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: Log4j for Multiple classes

2007-11-13 Thread Tursun Wali
Dear all,

I want to write a logger for my project . log file for single class is
Ok . log for  multiple classes seems problem to me .  I do not want to
allocate  one logger for one class , 10 logger for 10 class. I want to
some other smart way .
There was a post in mailing list by John  ([EMAIL PROTECTED]
) . tile is   "How to use Log4J in Multiple
classes? App Design? Date Tue, 12 Jul 2005 23:57:43
GMT

 John Hurt wrote:
>
> > Hi,
> >
> > My application is split up into multiple classes. If I had
> > processing in
> > each class that I wanted to log, what's the best way to make a
> > reference to
> > the Logger available, so that for instance they all write to the
> > same log
> > file?
> >
> > Do I create an instance of the Logger class at the beginning of the
> > program
> > flow, then pass that class to all the methods/classes that plan to do
> > logging?
> >
> > Do I make a wrapper singleton class that has a Logger in it and all
> > code
> > refers to the wrapper class?
> >
> > Do I use a base class (or interface or abstract class) that includes a
> > reference to a Logger class?
> >
> > Anyone has generic examples where Logger is used in more than 1
> > class, how
> > to use it gracefully? Thanks.
".
that is exactly what I want . but I could not contact with him . that
email address is not working .
Could you please one if you give me good advice !!!

Best Regards
Tom

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