Remove log4j and log4j2 support.
Projects can make and configure their own shim, but Java logging is a better default and log4j has been deprecated six ways to Sunday.
This commit is contained in:
@@ -44,20 +44,6 @@
|
||||
<version>6.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.16</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>2.0-rc2</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>mail</artifactId>
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
//
|
||||
// samskivert library - useful routines for java programs
|
||||
// Copyright (C) 2001-2012 Michael Bayne, et al.
|
||||
// http://github.com/samskivert/samskivert/blob/master/COPYING
|
||||
|
||||
package com.samskivert.util;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
/**
|
||||
* A factory for creating log4j2 logger implementations.
|
||||
*/
|
||||
public class Log4J2Logger implements Logger.Factory
|
||||
{
|
||||
// from interface Logger.Factory
|
||||
public void init ()
|
||||
{
|
||||
}
|
||||
|
||||
// from interface Logger.Factory
|
||||
public Logger getLogger (String name)
|
||||
{
|
||||
return new Impl(LogManager.getLogger(name));
|
||||
}
|
||||
|
||||
// from interface Logger.Factory
|
||||
public Logger getLogger (Class<?> clazz)
|
||||
{
|
||||
return new Impl(LogManager.getLogger(clazz));
|
||||
}
|
||||
|
||||
protected static class Impl extends Logger
|
||||
{
|
||||
public Impl (org.apache.logging.log4j.Logger impl)
|
||||
{
|
||||
_impl = impl;
|
||||
}
|
||||
|
||||
@Override // from Logger
|
||||
protected boolean shouldLog (int levIdx)
|
||||
{
|
||||
return _impl.isEnabled(LEVELS[levIdx]);
|
||||
}
|
||||
|
||||
@Override // from Logger
|
||||
protected void doLog (int levIdx, String formatted, Throwable throwable)
|
||||
{
|
||||
_impl.log(LEVELS[levIdx], formatted, throwable);
|
||||
}
|
||||
|
||||
protected final org.apache.logging.log4j.Logger _impl;
|
||||
protected static final Level[] LEVELS = {
|
||||
Level.DEBUG, Level.INFO, Level.WARN, Level.ERROR };
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
//
|
||||
// samskivert library - useful routines for java programs
|
||||
// Copyright (C) 2001-2012 Michael Bayne, et al.
|
||||
// http://github.com/samskivert/samskivert/blob/master/COPYING
|
||||
|
||||
package com.samskivert.util;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
|
||||
/**
|
||||
* A factory for creating log4j logger implementations.
|
||||
*/
|
||||
public class Log4JLogger implements Logger.Factory
|
||||
{
|
||||
// from interface Logger.Factory
|
||||
public void init ()
|
||||
{
|
||||
}
|
||||
|
||||
// from interface Logger.Factory
|
||||
public Logger getLogger (String name)
|
||||
{
|
||||
return new Impl(org.apache.log4j.Logger.getLogger(name));
|
||||
}
|
||||
|
||||
// from interface Logger.Factory
|
||||
public Logger getLogger (Class<?> clazz)
|
||||
{
|
||||
return getLogger(clazz.getName());
|
||||
}
|
||||
|
||||
protected static class Impl extends Logger
|
||||
{
|
||||
public Impl (org.apache.log4j.Logger impl)
|
||||
{
|
||||
_impl = impl;
|
||||
}
|
||||
|
||||
@Override // from Logger
|
||||
protected boolean shouldLog (int levIdx)
|
||||
{
|
||||
return _impl.isEnabledFor(LEVELS[levIdx]);
|
||||
}
|
||||
|
||||
@Override // from Logger
|
||||
protected void doLog (int levIdx, String formatted, Throwable throwable)
|
||||
{
|
||||
_impl.log(_self, LEVELS[levIdx], formatted, throwable);
|
||||
}
|
||||
|
||||
protected final org.apache.log4j.Logger _impl;
|
||||
protected final String _self = getClass().getName();
|
||||
protected static final Level[] LEVELS = {
|
||||
Level.DEBUG, Level.INFO, Level.WARN, Level.ERROR };
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,9 @@ package com.samskivert.util;
|
||||
* that they can be used in a larger project and easily be made to log to the logging framework in
|
||||
* use by that project.
|
||||
*
|
||||
* <p> The default implementation uses log4j if it is available and falls back to the Java logging
|
||||
* services if not. A specific (or custom) logging implementation can be configured like so:
|
||||
* <pre>-Dcom.samskivert.util.Logger=com.samskivert.util.Log4Logger</pre>
|
||||
* <p> The default implementation uses the Java logging services. A specific (or custom) logging
|
||||
* implementation can be configured like so:
|
||||
* <pre>-Dcom.samskivert.util.Logger=com.your.custom.Log4Logger</pre>
|
||||
*
|
||||
* <p> One additional enhancement is the use of varargs log methods to allow for some handy
|
||||
* automatic formatting. The methods take a log message and list of zero or more additional
|
||||
@@ -166,36 +166,10 @@ public abstract class Logger
|
||||
{
|
||||
// if a custom class was specified as a system property, use that
|
||||
Factory factory = createConfiguredFactory();
|
||||
|
||||
// create and a log4j logger if the log4j configuration system property is set
|
||||
try {
|
||||
if (factory == null && System.getProperty("log4j.configuration") != null) {
|
||||
factory = (Factory)Class.forName("com.samskivert.util.Log4JLogger").
|
||||
getDeclaredConstructor().newInstance();
|
||||
}
|
||||
} catch (SecurityException se) {
|
||||
// in a sandbox, no biggie
|
||||
} catch (Throwable t) {
|
||||
System.err.println("Unable to instantiate Log4JLogger: " + t);
|
||||
}
|
||||
|
||||
// create and a log4j2 logger if the log4j2 configuration system property is set
|
||||
try {
|
||||
if (factory == null && System.getProperty("log4j.configurationFile") != null) {
|
||||
factory = (Factory)Class.forName("com.samskivert.util.Log4J2Logger").
|
||||
getDeclaredConstructor().newInstance();
|
||||
}
|
||||
} catch (SecurityException se) {
|
||||
// in a sandbox, no biggie
|
||||
} catch (Throwable t) {
|
||||
System.err.println("Unable to instantiate Log4J2Logger: " + t);
|
||||
}
|
||||
|
||||
// lastly, fall back to the Java logging system
|
||||
// otherwise, use the Java logging system
|
||||
if (factory == null) {
|
||||
factory = new JDK14Logger();
|
||||
}
|
||||
|
||||
// and finally configure our factory
|
||||
setFactory(factory);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user