Replace tab characters with spaces. No other changes.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/logging/trunk@581090 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
28
build.xml
28
build.xml
@@ -526,8 +526,8 @@
|
|||||||
but try to load them by reflection from particular loaders.
|
but try to load them by reflection from particular loaders.
|
||||||
They will therefore fail unless this logger is available.
|
They will therefore fail unless this logger is available.
|
||||||
-->
|
-->
|
||||||
<include name='**/pathable/**'/>
|
<include name='**/pathable/**'/>
|
||||||
<!-- END NOTE -->
|
<!-- END NOTE -->
|
||||||
</javac>
|
</javac>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
@@ -541,21 +541,21 @@
|
|||||||
source="${source.version}"
|
source="${source.version}"
|
||||||
target="${target.version}">
|
target="${target.version}">
|
||||||
<classpath refid="test.classpath"/>
|
<classpath refid="test.classpath"/>
|
||||||
<include name='**/avalon/**'/>
|
<include name='**/avalon/**'/>
|
||||||
</javac>
|
</javac>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name='compile.logkit.tests' if='logkit.present'>
|
<target name='compile.logkit.tests' if='logkit.present'>
|
||||||
<javac srcdir="${test.home}"
|
<javac srcdir="${test.home}"
|
||||||
destdir="${build.home}/tests"
|
destdir="${build.home}/tests"
|
||||||
debug="${compile.debug}"
|
debug="${compile.debug}"
|
||||||
deprecation="${compile.deprecation}"
|
deprecation="${compile.deprecation}"
|
||||||
optimize="${compile.optimize}"
|
optimize="${compile.optimize}"
|
||||||
source="${source.version}"
|
source="${source.version}"
|
||||||
target="${target.version}">
|
target="${target.version}">
|
||||||
<classpath refid="test.classpath"/>
|
<classpath refid="test.classpath"/>
|
||||||
<include name='**/logkit/**'/>
|
<include name='**/logkit/**'/>
|
||||||
</javac>
|
</javac>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="compile.tests" depends="compile"
|
<target name="compile.tests" depends="compile"
|
||||||
@@ -584,7 +584,7 @@
|
|||||||
<antcall target='compile.log4j.tests'/>
|
<antcall target='compile.log4j.tests'/>
|
||||||
<antcall target='compile.jdk1.4.tests'/>
|
<antcall target='compile.jdk1.4.tests'/>
|
||||||
<antcall target='compile.avalon.tests'/>
|
<antcall target='compile.avalon.tests'/>
|
||||||
<antcall target='compile.logkit.tests'/>
|
<antcall target='compile.logkit.tests'/>
|
||||||
<copy todir="${build.home}/tests" filtering="on">
|
<copy todir="${build.home}/tests" filtering="on">
|
||||||
<fileset dir="${test.home}" excludes="**/*.java"/>
|
<fileset dir="${test.home}" excludes="**/*.java"/>
|
||||||
</copy>
|
</copy>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
<postGoal name="xdoc:copy-resources">
|
<postGoal name="xdoc:copy-resources">
|
||||||
<copy todir="${basedir}/target/docs/" failonerror="false">
|
<copy todir="${basedir}/target/docs/" failonerror="false">
|
||||||
<fileset dir="${basedir}">
|
<fileset dir="${basedir}">
|
||||||
<include name='RELEASE-NOTES.txt'/>
|
<include name='RELEASE-NOTES.txt'/>
|
||||||
</fileset>
|
</fileset>
|
||||||
</copy>
|
</copy>
|
||||||
</postGoal>
|
</postGoal>
|
||||||
|
|||||||
@@ -1092,7 +1092,7 @@ public abstract class LogFactory {
|
|||||||
*/
|
*/
|
||||||
protected static LogFactory newFactory(final String factoryClass,
|
protected static LogFactory newFactory(final String factoryClass,
|
||||||
final ClassLoader classLoader) {
|
final ClassLoader classLoader) {
|
||||||
return newFactory(factoryClass, classLoader, null);
|
return newFactory(factoryClass, classLoader, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1182,7 +1182,7 @@ public abstract class LogFactory {
|
|||||||
// loading with that loader (not the TCCL). Just throw an
|
// loading with that loader (not the TCCL). Just throw an
|
||||||
// appropriate exception here.
|
// appropriate exception here.
|
||||||
|
|
||||||
final boolean implementsLogFactory = implementsLogFactory(logFactoryClass);
|
final boolean implementsLogFactory = implementsLogFactory(logFactoryClass);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Construct a good message: users may not actual expect that a custom implementation
|
// Construct a good message: users may not actual expect that a custom implementation
|
||||||
@@ -1195,13 +1195,13 @@ public abstract class LogFactory {
|
|||||||
+ LogFactory.class.getName() + "'. ";
|
+ LogFactory.class.getName() + "'. ";
|
||||||
if (implementsLogFactory) {
|
if (implementsLogFactory) {
|
||||||
msg = msg + "The conflict is caused by the presence of multiple LogFactory classes in incompatible classloaders. " +
|
msg = msg + "The conflict is caused by the presence of multiple LogFactory classes in incompatible classloaders. " +
|
||||||
"Background can be found in http://commons.apache.org/logging/tech.html. " +
|
"Background can be found in http://commons.apache.org/logging/tech.html. " +
|
||||||
"If you have not explicitly specified a custom LogFactory then it is likely that " +
|
"If you have not explicitly specified a custom LogFactory then it is likely that " +
|
||||||
"the container has set one without your knowledge. " +
|
"the container has set one without your knowledge. " +
|
||||||
"In this case, consider using the commons-logging-adapters.jar file or " +
|
"In this case, consider using the commons-logging-adapters.jar file or " +
|
||||||
"specifying the standard LogFactory from the command line. ";
|
"specifying the standard LogFactory from the command line. ";
|
||||||
} else {
|
} else {
|
||||||
msg = msg + "Please check the custom implementation. ";
|
msg = msg + "Please check the custom implementation. ";
|
||||||
}
|
}
|
||||||
msg = msg + "Help can be found @http://commons.apache.org/logging/troubleshooting.html.";
|
msg = msg + "Help can be found @http://commons.apache.org/logging/troubleshooting.html.";
|
||||||
|
|
||||||
@@ -1563,31 +1563,31 @@ public abstract class LogFactory {
|
|||||||
*/
|
*/
|
||||||
private static void initDiagnostics() {
|
private static void initDiagnostics() {
|
||||||
String dest;
|
String dest;
|
||||||
try {
|
try {
|
||||||
dest = getSystemProperty(DIAGNOSTICS_DEST_PROPERTY, null);
|
dest = getSystemProperty(DIAGNOSTICS_DEST_PROPERTY, null);
|
||||||
if (dest == null) {
|
if (dest == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch(SecurityException ex) {
|
} catch(SecurityException ex) {
|
||||||
// We must be running in some very secure environment.
|
// We must be running in some very secure environment.
|
||||||
// We just have to assume output is not wanted..
|
// We just have to assume output is not wanted..
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dest.equals("STDOUT")) {
|
if (dest.equals("STDOUT")) {
|
||||||
diagnosticsStream = System.out;
|
diagnosticsStream = System.out;
|
||||||
} else if (dest.equals("STDERR")) {
|
} else if (dest.equals("STDERR")) {
|
||||||
diagnosticsStream = System.err;
|
diagnosticsStream = System.err;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
// open the file in append mode
|
// open the file in append mode
|
||||||
FileOutputStream fos = new FileOutputStream(dest, true);
|
FileOutputStream fos = new FileOutputStream(dest, true);
|
||||||
diagnosticsStream = new PrintStream(fos);
|
diagnosticsStream = new PrintStream(fos);
|
||||||
} catch(IOException ex) {
|
} catch(IOException ex) {
|
||||||
// We should report this to the user - but how?
|
// We should report this to the user - but how?
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// In order to avoid confusion where multiple instances of JCL are
|
// In order to avoid confusion where multiple instances of JCL are
|
||||||
// being used via different classloaders within the same app, we
|
// being used via different classloaders within the same app, we
|
||||||
|
|||||||
@@ -1364,9 +1364,9 @@ public class LogFactoryImpl extends LogFactory {
|
|||||||
+ discoveryFlaw.getLocalizedMessage());
|
+ discoveryFlaw.getLocalizedMessage());
|
||||||
|
|
||||||
if (discoveryFlaw instanceof InvocationTargetException ) {
|
if (discoveryFlaw instanceof InvocationTargetException ) {
|
||||||
// Ok, the lib is there but while trying to create a real underlying
|
// Ok, the lib is there but while trying to create a real underlying
|
||||||
// logger something failed in the underlying lib; display info about
|
// logger something failed in the underlying lib; display info about
|
||||||
// that if possible.
|
// that if possible.
|
||||||
InvocationTargetException ite = (InvocationTargetException)discoveryFlaw;
|
InvocationTargetException ite = (InvocationTargetException)discoveryFlaw;
|
||||||
Throwable cause = ite.getTargetException();
|
Throwable cause = ite.getTargetException();
|
||||||
if (cause != null) {
|
if (cause != null) {
|
||||||
|
|||||||
@@ -137,11 +137,11 @@ public class SimpleLog implements Log, Serializable {
|
|||||||
|
|
||||||
private static String getStringProperty(String name) {
|
private static String getStringProperty(String name) {
|
||||||
String prop = null;
|
String prop = null;
|
||||||
try {
|
try {
|
||||||
prop = System.getProperty(name);
|
prop = System.getProperty(name);
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
; // Ignore
|
; // Ignore
|
||||||
}
|
}
|
||||||
return (prop == null) ? simpleLogProps.getProperty(name) : prop;
|
return (prop == null) ? simpleLogProps.getProperty(name) : prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,7 +308,7 @@ public class SimpleLog implements Log, Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Append the name of the log instance if so configured
|
// Append the name of the log instance if so configured
|
||||||
if( showShortName) {
|
if( showShortName) {
|
||||||
if( shortLogName==null ) {
|
if( shortLogName==null ) {
|
||||||
// Cut all but the last component of the name for both styles
|
// Cut all but the last component of the name for both styles
|
||||||
shortLogName = logName.substring(logName.lastIndexOf(".") + 1);
|
shortLogName = logName.substring(logName.lastIndexOf(".") + 1);
|
||||||
|
|||||||
@@ -33,64 +33,64 @@ public abstract class AbstractLogTest extends TestCase {
|
|||||||
|
|
||||||
public abstract Log getLogObject();
|
public abstract Log getLogObject();
|
||||||
|
|
||||||
public void testLoggingWithNullParameters()
|
public void testLoggingWithNullParameters()
|
||||||
{
|
{
|
||||||
Log log = this.getLogObject();
|
Log log = this.getLogObject();
|
||||||
|
|
||||||
assertNotNull(log);
|
assertNotNull(log);
|
||||||
|
|
||||||
|
|
||||||
log.debug(null);
|
log.debug(null);
|
||||||
|
|
||||||
log.debug(null, null);
|
log.debug(null, null);
|
||||||
|
|
||||||
log.debug(log.getClass().getName() + ": debug statement");
|
log.debug(log.getClass().getName() + ": debug statement");
|
||||||
|
|
||||||
log.debug(log.getClass().getName() + ": debug statement w/ null exception", new RuntimeException());
|
log.debug(log.getClass().getName() + ": debug statement w/ null exception", new RuntimeException());
|
||||||
|
|
||||||
|
|
||||||
log.error(null);
|
log.error(null);
|
||||||
|
|
||||||
log.error(null, null);
|
log.error(null, null);
|
||||||
|
|
||||||
log.error(log.getClass().getName() + ": error statement");
|
log.error(log.getClass().getName() + ": error statement");
|
||||||
|
|
||||||
log.error(log.getClass().getName() + ": error statement w/ null exception", new RuntimeException());
|
log.error(log.getClass().getName() + ": error statement w/ null exception", new RuntimeException());
|
||||||
|
|
||||||
|
|
||||||
log.fatal(null);
|
log.fatal(null);
|
||||||
|
|
||||||
log.fatal(null, null);
|
log.fatal(null, null);
|
||||||
|
|
||||||
log.fatal(log.getClass().getName() + ": fatal statement");
|
log.fatal(log.getClass().getName() + ": fatal statement");
|
||||||
|
|
||||||
log.fatal(log.getClass().getName() + ": fatal statement w/ null exception", new RuntimeException());
|
log.fatal(log.getClass().getName() + ": fatal statement w/ null exception", new RuntimeException());
|
||||||
|
|
||||||
|
|
||||||
log.info(null);
|
log.info(null);
|
||||||
|
|
||||||
log.info(null, null);
|
log.info(null, null);
|
||||||
|
|
||||||
log.info(log.getClass().getName() + ": info statement");
|
log.info(log.getClass().getName() + ": info statement");
|
||||||
|
|
||||||
log.info(log.getClass().getName() + ": info statement w/ null exception", new RuntimeException());
|
log.info(log.getClass().getName() + ": info statement w/ null exception", new RuntimeException());
|
||||||
|
|
||||||
|
|
||||||
log.trace(null);
|
log.trace(null);
|
||||||
|
|
||||||
log.trace(null, null);
|
log.trace(null, null);
|
||||||
|
|
||||||
log.trace(log.getClass().getName() + ": trace statement");
|
log.trace(log.getClass().getName() + ": trace statement");
|
||||||
|
|
||||||
log.trace(log.getClass().getName() + ": trace statement w/ null exception", new RuntimeException());
|
log.trace(log.getClass().getName() + ": trace statement w/ null exception", new RuntimeException());
|
||||||
|
|
||||||
|
|
||||||
log.warn(null);
|
log.warn(null);
|
||||||
|
|
||||||
log.warn(null, null);
|
log.warn(null, null);
|
||||||
|
|
||||||
log.warn(log.getClass().getName() + ": warn statement");
|
log.warn(log.getClass().getName() + ": warn statement");
|
||||||
|
|
||||||
log.warn(log.getClass().getName() + ": warn statement w/ null exception", new RuntimeException());
|
log.warn(log.getClass().getName() + ": warn statement w/ null exception", new RuntimeException());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ import org.apache.commons.logging.impl.SimpleLog;
|
|||||||
*/
|
*/
|
||||||
public class SimpleLogTestCase extends AbstractLogTest
|
public class SimpleLogTestCase extends AbstractLogTest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public Log getLogObject()
|
public Log getLogObject()
|
||||||
{
|
{
|
||||||
return (Log) new SimpleLog(this.getClass().getName());
|
return (Log) new SimpleLog(this.getClass().getName());
|
||||||
|
|||||||
@@ -43,6 +43,6 @@ public class AvalonLoggerTestCase extends AbstractLogTest {
|
|||||||
|
|
||||||
public Log getLogObject() {
|
public Log getLogObject() {
|
||||||
Log log = new AvalonLogger(new ConsoleLogger());
|
Log log = new AvalonLogger(new ConsoleLogger());
|
||||||
return log;
|
return log;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,13 +53,13 @@ public class NoOpLogTestCase extends AbstractLogTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override the abstract method from the parent class so that the
|
* Override the abstract method from the parent class so that the
|
||||||
* inherited tests can access the right Log object type.
|
* inherited tests can access the right Log object type.
|
||||||
*/
|
*/
|
||||||
public Log getLogObject()
|
public Log getLogObject()
|
||||||
{
|
{
|
||||||
return (Log) new NoOpLog(this.getClass().getName());
|
return (Log) new NoOpLog(this.getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test Serializability of standard instance
|
// Test Serializability of standard instance
|
||||||
public void testSerializable() throws Exception {
|
public void testSerializable() throws Exception {
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ In most cases, including the (full) <code>commons-logging.jar</code> in the clas
|
|||||||
should result in JCL configuring itself in a reasonable manner.
|
should result in JCL configuring itself in a reasonable manner.
|
||||||
There's a good chance that it'll guess your preferred logging system and you won't
|
There's a good chance that it'll guess your preferred logging system and you won't
|
||||||
need to do any configuration at all!
|
need to do any configuration at all!
|
||||||
</p><p>
|
</p><p>
|
||||||
Note, however, that if you have a particular preference then providing a simple
|
Note, however, that if you have a particular preference then providing a simple
|
||||||
<code>commons-logging.properties</code> file which specifies the concrete logging library to be
|
<code>commons-logging.properties</code> file which specifies the concrete logging library to be
|
||||||
used is recommended, since (in this case) JCL will log only to that system
|
used is recommended, since (in this case) JCL will log only to that system
|
||||||
@@ -762,40 +762,40 @@ for details.
|
|||||||
</subsection>
|
</subsection>
|
||||||
</section>
|
</section>
|
||||||
<section name='A Quick Guide To Simple Log'>
|
<section name='A Quick Guide To Simple Log'>
|
||||||
<p>
|
<p>
|
||||||
JCL is distributed with a very simple <code>Log</code> implementation named
|
JCL is distributed with a very simple <code>Log</code> implementation named
|
||||||
<code>org.apache.commons.logging.impl.SimpleLog</code>. This is intended to be a minimal
|
<code>org.apache.commons.logging.impl.SimpleLog</code>. This is intended to be a minimal
|
||||||
implementation and those requiring a fully functional open source logging system are
|
implementation and those requiring a fully functional open source logging system are
|
||||||
directed to <a href='http://logging.apache.org/log4j'>Log4J</a>.
|
directed to <a href='http://logging.apache.org/log4j'>Log4J</a>.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<code>SimpleLog</code> sends all (enabled) log messages,
|
<code>SimpleLog</code> sends all (enabled) log messages,
|
||||||
for all defined loggers, to <code>System.err</code>. The following system properties
|
for all defined loggers, to <code>System.err</code>. The following system properties
|
||||||
are supported to configure the behavior of this logger:</p>
|
are supported to configure the behavior of this logger:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><strong>org.apache.commons.logging.simplelog.defaultlog</strong> -
|
<li><strong>org.apache.commons.logging.simplelog.defaultlog</strong> -
|
||||||
Default logging detail level for all instances of SimpleLog.
|
Default logging detail level for all instances of SimpleLog.
|
||||||
Must be one of:
|
Must be one of:
|
||||||
<ul>
|
<ul>
|
||||||
<li><code>trace</code></li>
|
<li><code>trace</code></li>
|
||||||
<li><code>debug</code></li>
|
<li><code>debug</code></li>
|
||||||
<li><code>info</code></li>
|
<li><code>info</code></li>
|
||||||
<li><code>warn</code></li>
|
<li><code>warn</code></li>
|
||||||
<li><code>error</code></li>
|
<li><code>error</code></li>
|
||||||
<li><code>fatal</code></li>
|
<li><code>fatal</code></li>
|
||||||
</ul>
|
</ul>
|
||||||
If not specified, defaults to <code>info</code>. </li>
|
If not specified, defaults to <code>info</code>. </li>
|
||||||
<li><strong>org.apache.commons.logging.simplelog.log.xxxxx</strong> -
|
<li><strong>org.apache.commons.logging.simplelog.log.xxxxx</strong> -
|
||||||
Logging detail level for a SimpleLog instance named "xxxxx".
|
Logging detail level for a SimpleLog instance named "xxxxx".
|
||||||
Must be one of:
|
Must be one of:
|
||||||
<ul>
|
<ul>
|
||||||
<li><code>trace</code></li>
|
<li><code>trace</code></li>
|
||||||
<li><code>debug</code></li>
|
<li><code>debug</code></li>
|
||||||
<li><code>info</code></li>
|
<li><code>info</code></li>
|
||||||
<li><code>warn</code></li>
|
<li><code>warn</code></li>
|
||||||
<li><code>error</code></li>
|
<li><code>error</code></li>
|
||||||
<li><code>fatal</code></li>
|
<li><code>fatal</code></li>
|
||||||
</ul>
|
</ul>
|
||||||
If not specified, the default logging detail level is used.</li>
|
If not specified, the default logging detail level is used.</li>
|
||||||
<li><strong>org.apache.commons.logging.simplelog.showlogname</strong> -
|
<li><strong>org.apache.commons.logging.simplelog.showlogname</strong> -
|
||||||
Set to <code>true</code> if you want the <code>Log</code> instance name to be
|
Set to <code>true</code> if you want the <code>Log</code> instance name to be
|
||||||
|
|||||||
1164
xdocs/tech.xml
1164
xdocs/tech.xml
File diff suppressed because it is too large
Load Diff
@@ -282,33 +282,33 @@ classloader used to load <code>LogFactory</code> and to the TCCL.
|
|||||||
</subsection>
|
</subsection>
|
||||||
</section>
|
</section>
|
||||||
<section name='Containers With Custom LogFactory Implementations'>
|
<section name='Containers With Custom LogFactory Implementations'>
|
||||||
<p>
|
<p>
|
||||||
Some containers use a custom <code>LogFactory</code> implementation to adapt JCL to their particular
|
Some containers use a custom <code>LogFactory</code> implementation to adapt JCL to their particular
|
||||||
logging system. This has some important consequences for the deployment of applications using JCL within
|
logging system. This has some important consequences for the deployment of applications using JCL within
|
||||||
these containers.
|
these containers.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Containers known to use this mechanism:
|
Containers known to use this mechanism:
|
||||||
</p>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href='http://www.ibm.com/software/websphere/'>WebSphere Application Server</a> from
|
<li><a href='http://www.ibm.com/software/websphere/'>WebSphere Application Server</a> from
|
||||||
<a href='http://www.ibm.com/software/websphere/'>IBM</a> (versions 5 and 6).</li>
|
<a href='http://www.ibm.com/software/websphere/'>IBM</a> (versions 5 and 6).</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>
|
<p>
|
||||||
Containers suspected to use this mechanism:
|
Containers suspected to use this mechanism:
|
||||||
</p>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>WebSphere Application Server (other versions).</li>
|
<li>WebSphere Application Server (other versions).</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>
|
<p>
|
||||||
The Apache Commons team would be grateful if reports were posted to the development list
|
The Apache Commons team would be grateful if reports were posted to the development list
|
||||||
of other containers using a custom implementation.
|
of other containers using a custom implementation.
|
||||||
</p>
|
</p>
|
||||||
<subsection name='The Incompatible LogFactory Issue'>
|
<subsection name='The Incompatible LogFactory Issue'>
|
||||||
<subsection name='Symptoms'>
|
<subsection name='Symptoms'>
|
||||||
<p>
|
<p>
|
||||||
An exception is thrown by JCL with a message similar to:
|
An exception is thrown by JCL with a message similar to:
|
||||||
</p>
|
</p>
|
||||||
<code><pre>
|
<code><pre>
|
||||||
The chosen LogFactory implementation does not extend LogFactory. Please check your configuration.
|
The chosen LogFactory implementation does not extend LogFactory. Please check your configuration.
|
||||||
(Caused by java.lang.ClassCastException: The application has specified that a custom LogFactory
|
(Caused by java.lang.ClassCastException: The application has specified that a custom LogFactory
|
||||||
@@ -320,26 +320,26 @@ of other containers using a custom implementation.
|
|||||||
In this case, consider using the commons-logging-adapters.jar file or specifying the standard
|
In this case, consider using the commons-logging-adapters.jar file or specifying the standard
|
||||||
LogFactory from the command line. Help can be found @http://commons.apache.org/logging.
|
LogFactory from the command line. Help can be found @http://commons.apache.org/logging.
|
||||||
</pre></code>
|
</pre></code>
|
||||||
<p>
|
<p>
|
||||||
This is a WebSphere example so the name of the custom LogFactory is
|
This is a WebSphere example so the name of the custom LogFactory is
|
||||||
<code>com.ibm.ws.commons.logging.TrLogFactory</code>. For other containers, this class name will
|
<code>com.ibm.ws.commons.logging.TrLogFactory</code>. For other containers, this class name will
|
||||||
differ.
|
differ.
|
||||||
</p>
|
</p>
|
||||||
</subsection>
|
</subsection>
|
||||||
<subsection name='Explanation'>
|
<subsection name='Explanation'>
|
||||||
<p>
|
<p>
|
||||||
A custom <code>LogFactory</code> implementation can only be used if the implementation class loaded
|
A custom <code>LogFactory</code> implementation can only be used if the implementation class loaded
|
||||||
dynamically at runtime can be cast to the <code>LogFactory</code> class that loaded it. There are
|
dynamically at runtime can be cast to the <code>LogFactory</code> class that loaded it. There are
|
||||||
several ways in which this cast can fail. The most obvious is that the source code may not actually
|
several ways in which this cast can fail. The most obvious is that the source code may not actually
|
||||||
extend <code>LogFactory</code>. The source may be compatible but if the <code>LogFactory</code> class
|
extend <code>LogFactory</code>. The source may be compatible but if the <code>LogFactory</code> class
|
||||||
against which the source is compiled is not binary compatible then the cast will also fail.
|
against which the source is compiled is not binary compatible then the cast will also fail.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
There is also another more unusual way in which this cast can fail: even when the binary is compatible,
|
There is also another more unusual way in which this cast can fail: even when the binary is compatible,
|
||||||
the implementation class loaded at runtime may be linked to a different instance of the
|
the implementation class loaded at runtime may be linked to a different instance of the
|
||||||
<code>LogFactory</code> class. For more information, see the <a href='tech.html'>tech guide</a>.
|
<code>LogFactory</code> class. For more information, see the <a href='tech.html'>tech guide</a>.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
This situation may be encountered in containers which use a custom <code>LogFactory</code> implementation.
|
This situation may be encountered in containers which use a custom <code>LogFactory</code> implementation.
|
||||||
The implementation will typically be provided in a shared, high level classloader together with JCL.
|
The implementation will typically be provided in a shared, high level classloader together with JCL.
|
||||||
When an application classloader contains <code>LogFactory</code>, the implementation will be loaded
|
When an application classloader contains <code>LogFactory</code>, the implementation will be loaded
|
||||||
@@ -347,8 +347,8 @@ of other containers using a custom implementation.
|
|||||||
class loaded by the higher level classloader. Even if the
|
class loaded by the higher level classloader. Even if the
|
||||||
<code>LogFactory</code> implementations are binary compatible, since they are loaded by different classloaders
|
<code>LogFactory</code> implementations are binary compatible, since they are loaded by different classloaders
|
||||||
the two <code>LogFactory</code> Class instances are not equal and so the cast must fail.
|
the two <code>LogFactory</code> Class instances are not equal and so the cast must fail.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
The policy adopted by JCL in this situation is to re-throw this exception. Additional information
|
The policy adopted by JCL in this situation is to re-throw this exception. Additional information
|
||||||
is included in the message to help diagnosis. The reasoning behind this choice is that a
|
is included in the message to help diagnosis. The reasoning behind this choice is that a
|
||||||
particular <code>LogFactory</code> implementation has been actively specified and this
|
particular <code>LogFactory</code> implementation has been actively specified and this
|
||||||
@@ -356,47 +356,47 @@ choice should not be ignored. This policy has unfortunate consequences when runn
|
|||||||
containers which have custom implementations: the above runtime exception may be thrown
|
containers which have custom implementations: the above runtime exception may be thrown
|
||||||
under certain classloading policies without the user knowingly specifying a custom
|
under certain classloading policies without the user knowingly specifying a custom
|
||||||
implementation.
|
implementation.
|
||||||
</p>
|
</p>
|
||||||
</subsection>
|
</subsection>
|
||||||
<subsection name='Fixes'>
|
<subsection name='Fixes'>
|
||||||
<p>
|
<p>
|
||||||
There are various ways to fix this problem. Which fix is right depends on the circumstances.
|
There are various ways to fix this problem. Which fix is right depends on the circumstances.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
If you are happy using another classloading policy for the application, select a
|
If you are happy using another classloading policy for the application, select a
|
||||||
classloading policy which ensures that <code>LogFactory</code> will be loaded from the
|
classloading policy which ensures that <code>LogFactory</code> will be loaded from the
|
||||||
shared classloader containing the custom implementation.
|
shared classloader containing the custom implementation.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
If you want to bypass the container adaption mechanism then set the appropriate system property
|
If you want to bypass the container adaption mechanism then set the appropriate system property
|
||||||
to the default value when the container is started:
|
to the default value when the container is started:
|
||||||
</p>
|
</p>
|
||||||
<code><pre>
|
<code><pre>
|
||||||
-Dorg.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl
|
-Dorg.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl
|
||||||
</pre></code>
|
</pre></code>
|
||||||
<p>
|
<p>
|
||||||
If you want to continue to use the default container mechanism then:
|
If you want to continue to use the default container mechanism then:
|
||||||
</p>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
Find and replace the commons-logging implementation used by the container with
|
Find and replace the commons-logging implementation used by the container with
|
||||||
the most modern release
|
the most modern release
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
Replace the commons-logging jar in the application with the commons-logging-adapters jar.
|
Replace the commons-logging jar in the application with the commons-logging-adapters jar.
|
||||||
This will ensure that application classloader will delegate to it's parent when loading
|
This will ensure that application classloader will delegate to it's parent when loading
|
||||||
<code>LogFactory</code>.
|
<code>LogFactory</code>.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>
|
<p>
|
||||||
If you encounter difficulties when applying the fixes recommended, please turn on
|
If you encounter difficulties when applying the fixes recommended, please turn on
|
||||||
<a href='#Using JCL Diagnostics'>diagnostics</a> and consult the logs.
|
<a href='#Using JCL Diagnostics'>diagnostics</a> and consult the logs.
|
||||||
</p>
|
</p>
|
||||||
</subsection>
|
</subsection>
|
||||||
</subsection>
|
</subsection>
|
||||||
</section>
|
</section>
|
||||||
<section name='Containers With Custom ClassLoading Behaviour for Logging'>
|
<section name='Containers With Custom ClassLoading Behaviour for Logging'>
|
||||||
<p>
|
<p>
|
||||||
Because commons-logging is such a fundamental library, some containers modify the way
|
Because commons-logging is such a fundamental library, some containers modify the way
|
||||||
in which classloading behaves for commons-logging classes.
|
in which classloading behaves for commons-logging classes.
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user