( we should probably add the other loggers - only what is found is used,
it doesn't hurt anyone ).
Even if most containers will automatically add whatever is in lib, if you
use it in command line things are more difficult.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138885 13f79535-47bb-0310-9956-ffa450edef68
- for JDK1.4, include the correct class/method. This uses a hack to
extract the information from the stack trace - probably slow, but
it's better to get the correct information.
- for log4j, check if log4j is initialized ( by checking if any appenders
are present ). Set a default configuration if it is not initialized.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138884 13f79535-47bb-0310-9956-ffa450edef68
even in environments (such as an Applet) where System.getProperty() throws
a security exception. Previously, this was causing the checks for Log4J or
JDK 1.4 logging to be skipped.
PR: Bugzilla #7468
Reported By: Tim Vernum (tpv at spamcop.net)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138881 13f79535-47bb-0310-9956-ffa450edef68
> I've updated the Log4JCategoryLog.java to use the Log4J method Category.log
> () which allows the fully qualified class name (FQCN) of the user's logger
> class to be passed through into Log4J. In this case the logger class FQCN
> will be "org.apache.commons.logging.impl.Log4JCategoryLog". This allows
> Log4J to correctly identify the location in the code from which the logger
> is being called, if required. Without this Log4J reports that the calling
> location is ALWAYS Log4JCategoryLog.java:132.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138878 13f79535-47bb-0310-9956-ffa450edef68
that the commons-logging wrapper is also available before selecting it.
This avoids problems when using a copy of commons-logging.jar compiled on
a 1.3 system (and therefore missing the wrappe class) when executing on a
1.4 system.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138875 13f79535-47bb-0310-9956-ffa450edef68
a loader, and the thread loader is set to point to a different
loader that doesn't include logging ( or to a wrong value ).
This happens when logging is used in certain container components,
where the thread loader will point to an app that may not
have/use logging.
XXX What's the right order ? From a 'feature' point of view,
it's better to try the thread loader first, so apps can
override the default. From a security point of view,
we should try the Class.forName() first, i.e. whatever
is loaded in the parent loader.
The current fix leaves the original order ( with thread loader
used if available ).
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138874 13f79535-47bb-0310-9956-ffa450edef68
A bit of change in reading the properties - I spent some time trying to
understand what was the original intention, it was quite tricky. If the
property is not set, the old code would have defaulted everything to
true.
Added a bit of code to display only the last component of the log name,
logs without log name are hard to trace back to the source, and the full
name can make things hard to read ( at least that's my experience so
far ).
Of course, feel free to change back, I'm just trying to get things
a bit easier to use 'out of box', config can override anything.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138868 13f79535-47bb-0310-9956-ffa450edef68
a logger package, and preferably use a specialized factory, which
can provide better integration with the real logger.
The introspection is ok, but it's limited and complex.
Also, switch to SimpleLog by default - which is almost the same as
using System.err.println(). If common logging requires the user to set
properties and configurations to get the same behavior as System.err(),
why would anyone use it ?
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138867 13f79535-47bb-0310-9956-ffa450edef68
to the logger impl, without introspection. The factory can be extended
to take advantage of other log4j features ( it calls getInstance(Class)
direclty for example ) to integrate better.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138865 13f79535-47bb-0310-9956-ffa450edef68
to use the standards ( if it makes sense ), and that's something that
works well enough ( crimson, xerces, xalan, saxon, etc).
Changed the code that deals with 'properties'-based setup. The propertis
will be set on the factory regardless of the discovery mechanism.
This may be arguable, but at least it's symetrical and permits the
application to pass the information to the logger implementation in
all cases. Given that the properties are read by the class loader,
each application can have it's own settings (even if
the admin sets a JVM-wide default by using a system property ).
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138862 13f79535-47bb-0310-9956-ffa450edef68
Jon plus some additional thought about using it in a multi-class-loader
environment (like Tomcat):
* Changed newFactory() to getFactory(), and implemented a cache of
previously created factory instances (one per class loader). This
avoids potentially expensive and redundant discovery operations.
* Added convenient static getLog() method so a typical application
component can initialize it's Log instance like this:
Log log = LogFactory.getLog("com.mycompany.mypackage.MyClass");
* Added variants of getInstance() and getLog() that take a Class
parameter instead of a String. LogSource had this convenience
feature, and there's no reason not to keep it.
* Added release() and releaseAll() methods to instruct the factory
instances to release any cached references to other LogFactory
or Log instances. This is important, for example, if you put
commons-logging.jar in Tomcat's shared "lib" directory, and then
use the application reload facility. The references maintained
here would otherwise prevent garbage collection of the old
webapp class loader once a reload takes place.
* Added a note on getInstance() that you can make no assumptions
about whether or not the actual Log instance you get back is
shared or not. The actual sharability is a feature of the
LogFactory implementation you are using, and what kind of a
class loader environment you ae installing.
* Deprecated LogSource, but left it there to ease transition of
existing code using it.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138858 13f79535-47bb-0310-9956-ffa450edef68
(LogFactoryImpl) that is based on the principles of the JAXP API's approach
to discovering SAXParserFactory and DocumentBuilderFactory instances. It
addresses the technical concerns that Costin brought up in response to the
original Commons Logging 1.0 vote.
The primary new features:
* Applications can select their own LogFactory implementations, not
just their own Log implementations. The default LogFactoryImpl
uses the same algorithm currently included in LogSource.
* The LogFactory implementation class can be specified by either a
system property (org.apache.commons.logging.LogFactory), or by a
corresponding property in a "commons-logging.properties" file found
somewhere in the class path.
* LogFactory implementations possess optional configuration attributes,
which are preloaded from the "commons-logging.properties" file if it
is found. These can be used by the factory to customize its own
behavior as needed.
* LogFactory and Log implementation classes are loaded from the
thread context class loader (if it is set) in a JDK 1.2 or later
environment. Hwoever, the entire API and default implementation should
still work on a JDK 1.1 system.
* A specialized exception (LogConfigurationException) is thrown for things
like missing LogFactory or Log implementation clases. This class
extends RuntimeException, so you normally don't have to put everything
in try/catch blocks unless you care about dealing with this in a
special way.
For applications currently using the pre-release version of the API, this
will typically mean replacing calls like this:
Log log = LogSource.getInstance("foo");
with calls like this:
Log log = LogFactory.newFactory().getInstance("foo");
unless you want to take advantage of the new capabilities.
If this factory approach is accepted, I propose that we take the actions:
* Deprecate LogSource (but leave it there for now, to assist existing
applications in their transition)
* Consider adding a setLogFactory() method to the Log interface -- and
the existing implementation classes -- to give them easy access to the
configuration attributes associated with the factory.
* Add unit tests for the new code (it's not really been tested yet).
* Propose the revised APIs as Commons-Logging 1.0 so that apps waiting
for a final release can know what API to depend on.
Follow-up technical discussions on this proposal should take place on
COMMONS-DEV. (If you want to argue about who can vote for what, please
start your own thread someplace else so we can get some work done :-).
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138856 13f79535-47bb-0310-9956-ffa450edef68
The code that this was based on was posted by Paulo Gaspar with a Java
package name of "krankikom.log.*" -- not exactly rousing evidence of
the fact that it came from Avalon.
Finally found the old mail message, and it did have Berin and Peter
as authors. Sure wish Paulo wouldn't arbitrarily change package names ...
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138848 13f79535-47bb-0310-9956-ffa450edef68
for debug. This way if commons-logging needs to define a lower level,
it will be able to do so. I am thinking about this because JBoss has
a TRACE level below debug.
PR:
Obtained from:
Submitted by:
Reviewed by:
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138847 13f79535-47bb-0310-9956-ffa450edef68