Sort members
This commit is contained in:
@@ -229,6 +229,39 @@ public abstract class LogFactory {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
protected static volatile LogFactory nullClassLoaderFactory;
|
protected static volatile LogFactory nullClassLoaderFactory;
|
||||||
|
|
||||||
|
static {
|
||||||
|
// note: it's safe to call methods before initDiagnostics (though
|
||||||
|
// diagnostic output gets discarded).
|
||||||
|
final ClassLoader thisClassLoader = getClassLoader(LogFactory.class);
|
||||||
|
thisClassLoaderRef = new WeakReference<>(thisClassLoader);
|
||||||
|
// In order to avoid confusion where multiple instances of JCL are
|
||||||
|
// being used via different class loaders within the same app, we
|
||||||
|
// ensure each logged message has a prefix of form
|
||||||
|
// [LogFactory from classloader OID]
|
||||||
|
//
|
||||||
|
// Note that this prefix should be kept consistent with that
|
||||||
|
// in LogFactoryImpl. However here we don't need to output info
|
||||||
|
// about the actual *instance* of LogFactory, as all methods that
|
||||||
|
// output diagnostics from this class are static.
|
||||||
|
String classLoaderName;
|
||||||
|
try {
|
||||||
|
if (thisClassLoader == null) {
|
||||||
|
classLoaderName = "BOOTLOADER";
|
||||||
|
} else {
|
||||||
|
classLoaderName = objectId(thisClassLoader);
|
||||||
|
}
|
||||||
|
} catch (final SecurityException e) {
|
||||||
|
classLoaderName = "UNKNOWN";
|
||||||
|
}
|
||||||
|
diagnosticPrefix = "[LogFactory from " + classLoaderName + "] ";
|
||||||
|
DIAGNOSTICS_STREAM = initDiagnostics();
|
||||||
|
logClassLoaderEnvironment(LogFactory.class);
|
||||||
|
factories = createFactoryStore();
|
||||||
|
if (isDiagnosticsEnabled()) {
|
||||||
|
logDiagnostic("BOOTSTRAP COMPLETED");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remember this factory, so later calls to LogFactory.getCachedFactory
|
* Remember this factory, so later calls to LogFactory.getCachedFactory
|
||||||
* can return the previously created object (together with all its
|
* can return the previously created object (together with all its
|
||||||
@@ -497,6 +530,7 @@ public abstract class LogFactory {
|
|||||||
return classLoader;
|
return classLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check cached factories (keyed by contextClassLoader)
|
* Check cached factories (keyed by contextClassLoader)
|
||||||
*
|
*
|
||||||
@@ -522,7 +556,6 @@ public abstract class LogFactory {
|
|||||||
return factories.get(contextClassLoader);
|
return factories.get(contextClassLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Safely get access to the classloader for the specified class.
|
* Safely get access to the classloader for the specified class.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -655,6 +688,7 @@ public abstract class LogFactory {
|
|||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current context classloader.
|
* Returns the current context classloader.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -676,7 +710,6 @@ public abstract class LogFactory {
|
|||||||
return directGetContextClassLoader();
|
return directGetContextClassLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls LogFactory.directGetContextClassLoader under the control of an
|
* Calls LogFactory.directGetContextClassLoader under the control of an
|
||||||
* AccessController class. This means that java code running under a
|
* AccessController class. This means that java code running under a
|
||||||
@@ -1042,6 +1075,7 @@ public abstract class LogFactory {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the specified system property, using an AccessController so that
|
* Read the specified system property, using an AccessController so that
|
||||||
* the property can be read if JCL has been granted the appropriate
|
* the property can be read if JCL has been granted the appropriate
|
||||||
@@ -1056,7 +1090,6 @@ public abstract class LogFactory {
|
|||||||
return AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty(key, def));
|
return AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty(key, def));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the supplied Throwable is one that needs to be
|
* Checks whether the supplied Throwable is one that needs to be
|
||||||
* re-thrown and ignores all others.
|
* re-thrown and ignores all others.
|
||||||
@@ -1559,7 +1592,7 @@ public abstract class LogFactory {
|
|||||||
* class loader would prevent garbage collection.
|
* class loader would prevent garbage collection.
|
||||||
*/
|
*/
|
||||||
public abstract void release();
|
public abstract void release();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove any configuration attribute associated with the specified name.
|
* Remove any configuration attribute associated with the specified name.
|
||||||
* If there is no such attribute, no action is taken.
|
* If there is no such attribute, no action is taken.
|
||||||
@@ -1567,17 +1600,6 @@ public abstract class LogFactory {
|
|||||||
* @param name Name of the attribute to remove
|
* @param name Name of the attribute to remove
|
||||||
*/
|
*/
|
||||||
public abstract void removeAttribute(String name);
|
public abstract void removeAttribute(String name);
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the configuration attribute with the specified name. Calling
|
|
||||||
* this with a {@code null} value is equivalent to calling
|
|
||||||
* {@code removeAttribute(name)}.
|
|
||||||
*
|
|
||||||
* @param name Name of the attribute to set
|
|
||||||
* @param value Value of the attribute to set, or {@code null}
|
|
||||||
* to remove any setting for this attribute
|
|
||||||
*/
|
|
||||||
public abstract void setAttribute(String name, Object value);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// We can't do this in the class constructor, as there are many
|
// We can't do this in the class constructor, as there are many
|
||||||
@@ -1595,37 +1617,15 @@ public abstract class LogFactory {
|
|||||||
// So the wisest thing to do is just to place this code at the very end
|
// So the wisest thing to do is just to place this code at the very end
|
||||||
// of the class file.
|
// of the class file.
|
||||||
|
|
||||||
static {
|
/**
|
||||||
// note: it's safe to call methods before initDiagnostics (though
|
* Sets the configuration attribute with the specified name. Calling
|
||||||
// diagnostic output gets discarded).
|
* this with a {@code null} value is equivalent to calling
|
||||||
final ClassLoader thisClassLoader = getClassLoader(LogFactory.class);
|
* {@code removeAttribute(name)}.
|
||||||
thisClassLoaderRef = new WeakReference<>(thisClassLoader);
|
*
|
||||||
// In order to avoid confusion where multiple instances of JCL are
|
* @param name Name of the attribute to set
|
||||||
// being used via different class loaders within the same app, we
|
* @param value Value of the attribute to set, or {@code null}
|
||||||
// ensure each logged message has a prefix of form
|
* to remove any setting for this attribute
|
||||||
// [LogFactory from classloader OID]
|
*/
|
||||||
//
|
public abstract void setAttribute(String name, Object value);
|
||||||
// Note that this prefix should be kept consistent with that
|
|
||||||
// in LogFactoryImpl. However here we don't need to output info
|
|
||||||
// about the actual *instance* of LogFactory, as all methods that
|
|
||||||
// output diagnostics from this class are static.
|
|
||||||
String classLoaderName;
|
|
||||||
try {
|
|
||||||
if (thisClassLoader == null) {
|
|
||||||
classLoaderName = "BOOTLOADER";
|
|
||||||
} else {
|
|
||||||
classLoaderName = objectId(thisClassLoader);
|
|
||||||
}
|
|
||||||
} catch (final SecurityException e) {
|
|
||||||
classLoaderName = "UNKNOWN";
|
|
||||||
}
|
|
||||||
diagnosticPrefix = "[LogFactory from " + classLoaderName + "] ";
|
|
||||||
DIAGNOSTICS_STREAM = initDiagnostics();
|
|
||||||
logClassLoaderEnvironment(LogFactory.class);
|
|
||||||
factories = createFactoryStore();
|
|
||||||
if (isDiagnosticsEnabled()) {
|
|
||||||
logDiagnostic("BOOTSTRAP COMPLETED");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,36 @@ public class Log4JLogger implements Log, Serializable {
|
|||||||
|
|
||||||
private static final Priority traceLevel;
|
private static final Priority traceLevel;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Note that this must come after the static variable declarations
|
||||||
|
// otherwise initializer expressions associated with those variables
|
||||||
|
// will override any settings done here.
|
||||||
|
//
|
||||||
|
// Verify that log4j is available, and that it is version 1.2.
|
||||||
|
// If an ExceptionInInitializerError is generated, then LogFactoryImpl
|
||||||
|
// will treat that as meaning that the appropriate underlying logging
|
||||||
|
// library is just not present - if discovery is in progress then
|
||||||
|
// discovery will continue.
|
||||||
|
static {
|
||||||
|
if (!Priority.class.isAssignableFrom(Level.class)) {
|
||||||
|
// nope, this is log4j 1.3, so force an ExceptionInInitializerError
|
||||||
|
throw new InstantiationError("Log4J 1.2 not available");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Releases of log4j1.2 >= 1.2.12 have Priority.TRACE available, earlier
|
||||||
|
// versions do not. If TRACE is not available, then we have to map
|
||||||
|
// calls to Log.trace(...) onto the DEBUG level.
|
||||||
|
|
||||||
|
Priority _traceLevel;
|
||||||
|
try {
|
||||||
|
_traceLevel = (Priority) Level.class.getDeclaredField("TRACE").get(null);
|
||||||
|
} catch (final Exception ex) {
|
||||||
|
// ok, trace not available
|
||||||
|
_traceLevel = Level.DEBUG;
|
||||||
|
}
|
||||||
|
traceLevel = _traceLevel;
|
||||||
|
}
|
||||||
|
|
||||||
/** Log to this logger */
|
/** Log to this logger */
|
||||||
private transient volatile Logger logger;
|
private transient volatile Logger logger;
|
||||||
|
|
||||||
@@ -301,34 +331,4 @@ public class Log4JLogger implements Log, Serializable {
|
|||||||
getLogger().log(FQCN, Level.WARN, message, t);
|
getLogger().log(FQCN, Level.WARN, message, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Note that this must come after the static variable declarations
|
|
||||||
// otherwise initializer expressions associated with those variables
|
|
||||||
// will override any settings done here.
|
|
||||||
//
|
|
||||||
// Verify that log4j is available, and that it is version 1.2.
|
|
||||||
// If an ExceptionInInitializerError is generated, then LogFactoryImpl
|
|
||||||
// will treat that as meaning that the appropriate underlying logging
|
|
||||||
// library is just not present - if discovery is in progress then
|
|
||||||
// discovery will continue.
|
|
||||||
static {
|
|
||||||
if (!Priority.class.isAssignableFrom(Level.class)) {
|
|
||||||
// nope, this is log4j 1.3, so force an ExceptionInInitializerError
|
|
||||||
throw new InstantiationError("Log4J 1.2 not available");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Releases of log4j1.2 >= 1.2.12 have Priority.TRACE available, earlier
|
|
||||||
// versions do not. If TRACE is not available, then we have to map
|
|
||||||
// calls to Log.trace(...) onto the DEBUG level.
|
|
||||||
|
|
||||||
Priority _traceLevel;
|
|
||||||
try {
|
|
||||||
_traceLevel = (Priority) Level.class.getDeclaredField("TRACE").get(null);
|
|
||||||
} catch (final Exception ex) {
|
|
||||||
// ok, trace not available
|
|
||||||
_traceLevel = Level.DEBUG;
|
|
||||||
}
|
|
||||||
traceLevel = _traceLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user