Re: How can I tell which log4j configuration file is being used?

2008-05-21 Thread Rob Davis-5

The logic for selecting the configuration file is in the LogManager.java
log4j class.

The environment variable you're looking for might be:
DEFAULT_INIT_OVERRIDE_KEY
Do you remember where you set this?

I'd like to know how you stop it looking at both files and instead allow the
user to do BasicConfigurator.configure(); 

First log4j will look for the log4j.properties files
Then if it doesnt find this it will look for the log4j.xml file

If you want to see which one is has selected, use  -Dlog4j.debug in your JVM
arguments when you run your program.


-- 
View this message in context: 
http://www.nabble.com/How-can-I-tell-which-log4j-configuration-file-is-being-used--tp17353608p17364347.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


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



RE: Simple log4j setup 1) to System.out.println (or eclipse console) or 2) file and 3) enableable at runtime + without need for log4j.xml ?

2008-04-30 Thread Rob Davis-5

Michael - thank you very much - I will try out your suggestion and report
back.

Your solution to my request to configure without log4j.xml is definitely an
option I want to use.

Also, just for info, for anyone else out there just starting out with log4j,
I've done some more digging and found some more pages:

If you want to see how log4j is attempting to get config information:
http://wiki.apache.org/logging-log4j/Log4jConfigurationHelp

If you want a quick example log4j.xml file to get going:
http://wiki.apache.org/logging-log4j/Log4jXmlFormat
tip: you can place this log4j.xml file at the top of your source tree /src
and it should find it at runtime. However you'll also need the log4j.dtd
(that comes with the source code of log4j zipped) and you must place this
log4j.dtd in the folder ..\org\apache\log4j\xml in your source tree as it is
reporting as otherwise missing/cannot find (if you look at
Log4jEntityResolver - that gave me a clue as to where it go and looks for
the dtd!).  And placing the files as I suggest will ensure that it runs in
Eclipse (3.3.x) and produces your logs in the console output.

I've replaced all my System.out.println with calls to the Apache Commons
Logging interfaces (which are implemented by log4j, which is actually the
default logging implementation for that). I call log.trace so I had to
change the example log4j.xml at
http://wiki.apache.org/logging-log4j/Log4jXmlFormat to use  to be able to see my logs.

So this example setup just outputs to System.out.println But for production
I'll be using Michael's example to configure where/enable the logging goes. 

However, it would be nice if the underlying logging system could be
configured via methods on the Apache Commons Logging Interfaces so that the
developer does not need to know about how to set it up.

There's also a PDF book on log4j by its creator, for purchase at: 
https://www.qos.ch/shop/products/log4j/log4j-Manual.jsp

which I might get at some point. 

-- 
View this message in context: 
http://www.nabble.com/Simple-log4j-setup-1%29-to-System.out.println-%28or-eclipse-console%29-or-2%29-file-and-3%29-enableable-at-runtime-%2B-without-need-for-log4j.xml---tp16964275p16984701.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


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



Simple log4j setup 1) to System.out.println (or eclipse console) or 2) file and 3) enableable at runtime + without need for log4j.xml ?

2008-04-29 Thread Rob Davis-5

Hi, I'm looking at setting up a simple log4j setup to:
1) output logs to System.out.println (or the Eclipse console) when
developing software
2) output to file(s) when the software is used in production
3) enableable/disableable at runtime - e.g. via a method

Is this possible without using a log4j.xml file ?
Is there a log4j class that I can call methods on directly to set up the
above three things?

If I do wish to use a log4j.xml then is there an example log4j.xml file I
can look at? The links to examples at
http://logging.apache.org/log4j/1.2/apidocs/index.html are broken

I've tried to read the documentation but there is too much for the simple
set up that I want to start with. For example the 'short introduction' at:
http://logging.apache.org/log4j/1.2/manual.html isn't really that short and
has lots of information that I don't need at this stage.

I've also searched this forum too but not found a simple getting started
guide.

Please help. Thanks.

-- 
View this message in context: 
http://www.nabble.com/Simple-log4j-setup-1%29-to-System.out.println-%28or-eclipse-console%29-or-2%29-file-and-3%29-enableable-at-runtime-%2B-without-need-for-log4j.xml---tp16964275p16964275.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


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