1
0

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:
Dennis Lundberg
2007-10-01 22:01:06 +00:00
parent 78942c8588
commit 051b217ae3
12 changed files with 791 additions and 791 deletions

View File

@@ -526,8 +526,8 @@
but try to load them by reflection from particular loaders.
They will therefore fail unless this logger is available.
-->
<include name='**/pathable/**'/>
<!-- END NOTE -->
<include name='**/pathable/**'/>
<!-- END NOTE -->
</javac>
</target>
@@ -541,23 +541,23 @@
source="${source.version}"
target="${target.version}">
<classpath refid="test.classpath"/>
<include name='**/avalon/**'/>
<include name='**/avalon/**'/>
</javac>
</target>
<target name='compile.logkit.tests' if='logkit.present'>
<javac srcdir="${test.home}"
destdir="${build.home}/tests"
debug="${compile.debug}"
deprecation="${compile.deprecation}"
optimize="${compile.optimize}"
source="${source.version}"
target="${target.version}">
<classpath refid="test.classpath"/>
<include name='**/logkit/**'/>
</javac>
<javac srcdir="${test.home}"
destdir="${build.home}/tests"
debug="${compile.debug}"
deprecation="${compile.deprecation}"
optimize="${compile.optimize}"
source="${source.version}"
target="${target.version}">
<classpath refid="test.classpath"/>
<include name='**/logkit/**'/>
</javac>
</target>
<target name="compile.tests" depends="compile"
description="Compile unit test cases">
<javac srcdir="${test.home}"
@@ -584,7 +584,7 @@
<antcall target='compile.log4j.tests'/>
<antcall target='compile.jdk1.4.tests'/>
<antcall target='compile.avalon.tests'/>
<antcall target='compile.logkit.tests'/>
<antcall target='compile.logkit.tests'/>
<copy todir="${build.home}/tests" filtering="on">
<fileset dir="${test.home}" excludes="**/*.java"/>
</copy>

View File

@@ -36,7 +36,7 @@
<postGoal name="xdoc:copy-resources">
<copy todir="${basedir}/target/docs/" failonerror="false">
<fileset dir="${basedir}">
<include name='RELEASE-NOTES.txt'/>
<include name='RELEASE-NOTES.txt'/>
</fileset>
</copy>
</postGoal>

View File

@@ -1092,7 +1092,7 @@ public abstract class LogFactory {
*/
protected static LogFactory newFactory(final String factoryClass,
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
// 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
@@ -1195,13 +1195,13 @@ public abstract class LogFactory {
+ LogFactory.class.getName() + "'. ";
if (implementsLogFactory) {
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. " +
"If you have not explicitly specified a custom LogFactory then it is likely that " +
"the container has set one without your knowledge. " +
"In this case, consider using the commons-logging-adapters.jar file or " +
"specifying the standard LogFactory from the command line. ";
"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 " +
"the container has set one without your knowledge. " +
"In this case, consider using the commons-logging-adapters.jar file or " +
"specifying the standard LogFactory from the command line. ";
} 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.";
@@ -1563,31 +1563,31 @@ public abstract class LogFactory {
*/
private static void initDiagnostics() {
String dest;
try {
dest = getSystemProperty(DIAGNOSTICS_DEST_PROPERTY, null);
if (dest == null) {
return;
}
} catch(SecurityException ex) {
// We must be running in some very secure environment.
// We just have to assume output is not wanted..
return;
}
if (dest.equals("STDOUT")) {
diagnosticsStream = System.out;
} else if (dest.equals("STDERR")) {
diagnosticsStream = System.err;
} else {
try {
try {
dest = getSystemProperty(DIAGNOSTICS_DEST_PROPERTY, null);
if (dest == null) {
return;
}
} catch(SecurityException ex) {
// We must be running in some very secure environment.
// We just have to assume output is not wanted..
return;
}
if (dest.equals("STDOUT")) {
diagnosticsStream = System.out;
} else if (dest.equals("STDERR")) {
diagnosticsStream = System.err;
} else {
try {
// open the file in append mode
FileOutputStream fos = new FileOutputStream(dest, true);
diagnosticsStream = new PrintStream(fos);
} catch(IOException ex) {
// We should report this to the user - but how?
return;
}
}
FileOutputStream fos = new FileOutputStream(dest, true);
diagnosticsStream = new PrintStream(fos);
} catch(IOException ex) {
// We should report this to the user - but how?
return;
}
}
// In order to avoid confusion where multiple instances of JCL are
// being used via different classloaders within the same app, we

View File

@@ -1364,9 +1364,9 @@ public class LogFactoryImpl extends LogFactory {
+ discoveryFlaw.getLocalizedMessage());
if (discoveryFlaw instanceof InvocationTargetException ) {
// Ok, the lib is there but while trying to create a real underlying
// logger something failed in the underlying lib; display info about
// that if possible.
// Ok, the lib is there but while trying to create a real underlying
// logger something failed in the underlying lib; display info about
// that if possible.
InvocationTargetException ite = (InvocationTargetException)discoveryFlaw;
Throwable cause = ite.getTargetException();
if (cause != null) {

View File

@@ -137,11 +137,11 @@ public class SimpleLog implements Log, Serializable {
private static String getStringProperty(String name) {
String prop = null;
try {
prop = System.getProperty(name);
} catch (SecurityException e) {
; // Ignore
}
try {
prop = System.getProperty(name);
} catch (SecurityException e) {
; // Ignore
}
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
if( showShortName) {
if( showShortName) {
if( shortLogName==null ) {
// Cut all but the last component of the name for both styles
shortLogName = logName.substring(logName.lastIndexOf(".") + 1);

View File

@@ -33,64 +33,64 @@ public abstract class AbstractLogTest extends TestCase {
public abstract Log getLogObject();
public void testLoggingWithNullParameters()
{
Log log = this.getLogObject();
assertNotNull(log);
public void testLoggingWithNullParameters()
{
Log log = this.getLogObject();
log.debug(null);
log.debug(null, null);
log.debug(log.getClass().getName() + ": debug statement");
log.debug(log.getClass().getName() + ": debug statement w/ null exception", new RuntimeException());
assertNotNull(log);
log.error(null);
log.error(null, null);
log.error(log.getClass().getName() + ": error statement");
log.error(log.getClass().getName() + ": error statement w/ null exception", new RuntimeException());
log.fatal(null);
log.fatal(null, null);
log.fatal(log.getClass().getName() + ": fatal statement");
log.fatal(log.getClass().getName() + ": fatal statement w/ null exception", new RuntimeException());
log.debug(null);
log.info(null);
log.info(null, null);
log.info(log.getClass().getName() + ": info statement");
log.info(log.getClass().getName() + ": info statement w/ null exception", new RuntimeException());
log.debug(null, null);
log.trace(null);
log.trace(null, null);
log.trace(log.getClass().getName() + ": trace statement");
log.trace(log.getClass().getName() + ": trace statement w/ null exception", new RuntimeException());
log.debug(log.getClass().getName() + ": debug statement");
log.warn(null);
log.warn(null, null);
log.warn(log.getClass().getName() + ": warn statement");
log.warn(log.getClass().getName() + ": warn statement w/ null exception", new RuntimeException());
}
log.debug(log.getClass().getName() + ": debug statement w/ null exception", new RuntimeException());
log.error(null);
log.error(null, null);
log.error(log.getClass().getName() + ": error statement");
log.error(log.getClass().getName() + ": error statement w/ null exception", new RuntimeException());
log.fatal(null);
log.fatal(null, null);
log.fatal(log.getClass().getName() + ": fatal statement");
log.fatal(log.getClass().getName() + ": fatal statement w/ null exception", new RuntimeException());
log.info(null);
log.info(null, null);
log.info(log.getClass().getName() + ": info statement");
log.info(log.getClass().getName() + ": info statement w/ null exception", new RuntimeException());
log.trace(null);
log.trace(null, null);
log.trace(log.getClass().getName() + ": trace statement");
log.trace(log.getClass().getName() + ": trace statement w/ null exception", new RuntimeException());
log.warn(null);
log.warn(null, null);
log.warn(log.getClass().getName() + ": warn statement");
log.warn(log.getClass().getName() + ": warn statement w/ null exception", new RuntimeException());
}
}

View File

@@ -29,11 +29,11 @@ import org.apache.commons.logging.impl.SimpleLog;
*/
public class SimpleLogTestCase extends AbstractLogTest
{
/**
*
*
*
*/
/**
*
*
*
*/
public Log getLogObject()
{
return (Log) new SimpleLog(this.getClass().getName());
@@ -41,6 +41,6 @@ public class SimpleLogTestCase extends AbstractLogTest
public static void main(String[] args) {
String[] testCaseName = { SimpleLogTestCase.class.getName() };
junit.textui.TestRunner.main(testCaseName);
junit.textui.TestRunner.main(testCaseName);
}
}

View File

@@ -32,7 +32,7 @@ public class AvalonLoggerTestCase extends AbstractLogTest {
public static void main(String[] args) {
String[] testCaseName = { AvalonLoggerTestCase.class.getName() };
junit.textui.TestRunner.main(testCaseName);
junit.textui.TestRunner.main(testCaseName);
}
public static Test suite() {
@@ -43,6 +43,6 @@ public class AvalonLoggerTestCase extends AbstractLogTest {
public Log getLogObject() {
Log log = new AvalonLogger(new ConsoleLogger());
return log;
}
return log;
}
}

View File

@@ -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.
*/
public Log getLogObject()
{
return (Log) new NoOpLog(this.getClass().getName());
}
*/
public Log getLogObject()
{
return (Log) new NoOpLog(this.getClass().getName());
}
// Test Serializability of standard instance
public void testSerializable() throws Exception {

View File

@@ -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.
There's a good chance that it'll guess your preferred logging system and you won't
need to do any configuration at all!
</p><p>
</p><p>
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
used is recommended, since (in this case) JCL will log only to that system
@@ -762,40 +762,40 @@ for details.
</subsection>
</section>
<section name='A Quick Guide To Simple Log'>
<p>
<p>
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
implementation and those requiring a fully functional open source logging system are
directed to <a href='http://logging.apache.org/log4j'>Log4J</a>.
</p>
<p>
<code>SimpleLog</code> sends all (enabled) log messages,
for all defined loggers, to <code>System.err</code>. The following system properties
</p>
<p>
<code>SimpleLog</code> sends all (enabled) log messages,
for all defined loggers, to <code>System.err</code>. The following system properties
are supported to configure the behavior of this logger:</p>
<ul>
<li><strong>org.apache.commons.logging.simplelog.defaultlog</strong> -
Default logging detail level for all instances of SimpleLog.
Must be one of:
<ul>
<li><code>trace</code></li>
<li><code>debug</code></li>
<li><code>info</code></li>
<li><code>warn</code></li>
<li><code>error</code></li>
<li><code>fatal</code></li>
</ul>
<ul>
<li><code>trace</code></li>
<li><code>debug</code></li>
<li><code>info</code></li>
<li><code>warn</code></li>
<li><code>error</code></li>
<li><code>fatal</code></li>
</ul>
If not specified, defaults to <code>info</code>. </li>
<li><strong>org.apache.commons.logging.simplelog.log.xxxxx</strong> -
Logging detail level for a SimpleLog instance named "xxxxx".
Must be one of:
<ul>
<li><code>trace</code></li>
<li><code>debug</code></li>
<li><code>info</code></li>
<li><code>warn</code></li>
<li><code>error</code></li>
<li><code>fatal</code></li>
</ul>
<ul>
<li><code>trace</code></li>
<li><code>debug</code></li>
<li><code>info</code></li>
<li><code>warn</code></li>
<li><code>error</code></li>
<li><code>fatal</code></li>
</ul>
If not specified, the default logging detail level is used.</li>
<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

File diff suppressed because it is too large Load Diff

View File

@@ -282,33 +282,33 @@ classloader used to load <code>LogFactory</code> and to the TCCL.
</subsection>
</section>
<section name='Containers With Custom LogFactory Implementations'>
<p>
<p>
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
these containers.
</p>
<p>
</p>
<p>
Containers known to use this mechanism:
</p>
<ul>
<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>
</ul>
<p>
</p>
<ul>
<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>
</ul>
<p>
Containers suspected to use this mechanism:
</p>
<ul>
<li>WebSphere Application Server (other versions).</li>
</ul>
<p>
</p>
<ul>
<li>WebSphere Application Server (other versions).</li>
</ul>
<p>
The Apache Commons team would be grateful if reports were posted to the development list
of other containers using a custom implementation.
</p>
<subsection name='The Incompatible LogFactory Issue'>
<subsection name='Symptoms'>
<p>
</p>
<subsection name='The Incompatible LogFactory Issue'>
<subsection name='Symptoms'>
<p>
An exception is thrown by JCL with a message similar to:
</p>
</p>
<code><pre>
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
@@ -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
LogFactory from the command line. Help can be found @http://commons.apache.org/logging.
</pre></code>
<p>
<p>
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
differ.
</p>
</subsection>
<subsection name='Explanation'>
<p>
</p>
</subsection>
<subsection name='Explanation'>
<p>
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
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
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,
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>.
</p>
<p>
</p>
<p>
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.
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
<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.
</p>
<p>
</p>
<p>
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
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
under certain classloading policies without the user knowingly specifying a custom
implementation.
</p>
</subsection>
<subsection name='Fixes'>
<p>
</p>
</subsection>
<subsection name='Fixes'>
<p>
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
classloading policy which ensures that <code>LogFactory</code> will be loaded from the
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
to the default value when the container is started:
</p>
</p>
<code><pre>
-Dorg.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl
</pre></code>
<p>
<p>
If you want to continue to use the default container mechanism then:
</p>
<ul>
<li>
</p>
<ul>
<li>
Find and replace the commons-logging implementation used by the container with
the most modern release
</li>
<li>
the most modern release
</li>
<li>
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
<code>LogFactory</code>.
</li>
</ul>
<p>
</li>
</ul>
<p>
If you encounter difficulties when applying the fixes recommended, please turn on
<a href='#Using JCL Diagnostics'>diagnostics</a> and consult the logs.
</p>
</subsection>
</subsection>
</p>
</subsection>
</subsection>
</section>
<section name='Containers With Custom ClassLoading Behaviour for Logging'>
<p>
<p>
Because commons-logging is such a fundamental library, some containers modify the way
in which classloading behaves for commons-logging classes.
</p>