Logging: Make ESLoggerFactory package private (#34199)

Since all calls to `ESLoggerFactory` outside of the logging package were
deprecated, it seemed like it'd simplify things to migrate all of the
deprecated calls and declare `ESLoggerFactory` to be package private.
This does that.
This commit is contained in:
Nik Everett 2018-10-06 09:54:08 -04:00 committed by GitHub
parent c6c83d19f7
commit 06993e0c35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 60 additions and 74 deletions

View File

@ -23,10 +23,10 @@ import com.github.mustachejava.MustacheException;
import com.github.mustachejava.MustacheFactory;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.logging.log4j.util.Supplier;
import org.elasticsearch.SpecialPermission;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.script.GeneralScriptException;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptContext;
@ -51,7 +51,7 @@ import java.util.Map;
* {@link Mustache} object can then be re-used for subsequent executions.
*/
public final class MustacheScriptEngine implements ScriptEngine {
private static final Logger logger = ESLoggerFactory.getLogger(MustacheScriptEngine.class);
private static final Logger logger = LogManager.getLogger(MustacheScriptEngine.class);
public static final String NAME = "mustache";

View File

@ -20,8 +20,8 @@
package org.elasticsearch.painless;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.common.io.PathUtils;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.core.internal.io.IOUtils;
import org.elasticsearch.painless.lookup.PainlessClass;
import org.elasticsearch.painless.lookup.PainlessConstructor;
@ -55,7 +55,7 @@ import static java.util.Comparator.comparing;
public class PainlessDocGenerator {
private static final PainlessLookup PAINLESS_LOOKUP = PainlessLookupBuilder.buildFromWhitelists(Whitelist.BASE_WHITELISTS);
private static final Logger logger = ESLoggerFactory.getLogger(PainlessDocGenerator.class);
private static final Logger logger = LogManager.getLogger(PainlessDocGenerator.class);
private static final Comparator<PainlessField> FIELD_NAME = comparing(f -> f.javaField.getName());
private static final Comparator<PainlessMethod> METHOD_NAME = comparing(m -> m.javaMethod.getName());
private static final Comparator<PainlessMethod> METHOD_NUMBER_OF_PARAMS = comparing(m -> m.typeParameters.size());

View File

@ -20,6 +20,7 @@
package org.elasticsearch.action;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplainAction;
import org.elasticsearch.action.admin.cluster.allocation.TransportClusterAllocationExplainAction;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction;
@ -200,7 +201,6 @@ import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.common.NamedRegistry;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.multibindings.MapBinder;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.IndexScopedSettings;
import org.elasticsearch.common.settings.Settings;
@ -336,7 +336,7 @@ import static java.util.Collections.unmodifiableMap;
*/
public class ActionModule extends AbstractModule {
private static final Logger logger = ESLoggerFactory.getLogger(ActionModule.class);
private static final Logger logger = LogManager.getLogger(ActionModule.class);
private final boolean transportClient;
private final Settings settings;

View File

@ -20,6 +20,7 @@
package org.elasticsearch.action.bulk;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.action.DocWriteRequest;
@ -48,7 +49,6 @@ import org.elasticsearch.common.CheckedSupplier;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentHelper;
@ -80,7 +80,7 @@ public class TransportShardBulkAction extends TransportWriteAction<BulkShardRequ
public static final String ACTION_NAME = BulkAction.NAME + "[s]";
private static final Logger logger = ESLoggerFactory.getLogger(TransportShardBulkAction.class);
private static final Logger logger = LogManager.getLogger(TransportShardBulkAction.class);
private final ThreadPool threadPool;
private final UpdateHelper updateHelper;

View File

@ -19,8 +19,8 @@
package org.elasticsearch.bootstrap;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.appender.ConsoleAppender;
@ -34,7 +34,6 @@ import org.elasticsearch.cli.UserException;
import org.elasticsearch.common.PidFile;
import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.inject.CreationException;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.logging.LogConfigurator;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.network.IfConfig;
@ -193,7 +192,7 @@ final class Bootstrap {
try {
// look for jar hell
final Logger logger = ESLoggerFactory.getLogger(JarHell.class);
final Logger logger = LogManager.getLogger(JarHell.class);
JarHell.checkJarHell(logger::debug);
} catch (IOException | URISyntaxException e) {
throw new BootstrapException(e);

View File

@ -26,17 +26,17 @@ import org.apache.logging.log4j.spi.ExtendedLogger;
/**
* Factory to get {@link Logger}s
*/
public final class ESLoggerFactory {
final class ESLoggerFactory {
private ESLoggerFactory() {
}
public static Logger getLogger(String prefix, String name) {
static Logger getLogger(String prefix, String name) {
return getLogger(prefix, LogManager.getLogger(name));
}
public static Logger getLogger(String prefix, Class<?> clazz) {
static Logger getLogger(String prefix, Class<?> clazz) {
/*
* At one point we didn't use LogManager.getLogger(clazz) because
* of a bug in log4j that has since been fixed:
@ -49,7 +49,7 @@ public final class ESLoggerFactory {
return getLogger(prefix, LogManager.getLogger(clazz.getName()));
}
public static Logger getLogger(String prefix, Logger logger) {
static Logger getLogger(String prefix, Logger logger) {
/*
* In a followup we'll throw an exception if prefix is null or empty
* redirecting folks to LogManager.getLogger.
@ -61,13 +61,4 @@ public final class ESLoggerFactory {
}
return new PrefixLogger((ExtendedLogger)logger, logger.getName(), prefix);
}
/**
* Get or build a logger.
* @deprecated Prefer {@link LogManager#getLogger}
*/
@Deprecated
public static Logger getLogger(Class<?> clazz) {
return getLogger(null, clazz);
}
}

View File

@ -91,7 +91,7 @@ public class Loggers {
*/
@Deprecated
public static Logger getLogger(Class<?> clazz) {
return ESLoggerFactory.getLogger(clazz);
return ESLoggerFactory.getLogger(null, clazz);
}
private static String formatPrefix(String... prefixes) {

View File

@ -20,9 +20,9 @@
package org.elasticsearch.common.util.concurrent;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.elasticsearch.common.ExponentiallyWeightedMovingAverage;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.unit.TimeValue;
import java.util.Locale;
@ -41,8 +41,7 @@ public final class QueueResizingEsThreadPoolExecutor extends EsThreadPoolExecuto
// This is a random starting point alpha. TODO: revisit this with actual testing and/or make it configurable
public static double EWMA_ALPHA = 0.3;
private static final Logger logger =
ESLoggerFactory.getLogger(QueueResizingEsThreadPoolExecutor.class);
private static final Logger logger = LogManager.getLogger(QueueResizingEsThreadPoolExecutor.class);
// The amount the queue size is adjusted by for each calcuation
private static final int QUEUE_ADJUSTMENT_AMOUNT = 50;

View File

@ -18,12 +18,13 @@
*/
package org.elasticsearch.common.util.concurrent;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.lucene.util.CloseableThreadLocal;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property;
import org.elasticsearch.common.settings.Settings;
@ -83,6 +84,7 @@ public final class ThreadContext implements Closeable, Writeable {
public static final String PREFIX = "request.headers";
public static final Setting<Settings> DEFAULT_HEADERS_SETTING = Setting.groupSetting(PREFIX + ".", Property.NodeScope);
private static final Logger logger = LogManager.getLogger(ThreadContext.class);
private static final ThreadContextStruct DEFAULT_CONTEXT = new ThreadContextStruct();
private final Map<String, String> defaultHeader;
private final ContextThreadLocal threadLocal;
@ -469,18 +471,16 @@ public final class ThreadContext implements Closeable, Writeable {
//check if we can add another warning header - if max size within limits
if (key.equals("Warning") && (maxWarningHeaderSize != -1)) { //if size is NOT unbounded, check its limits
if (warningHeadersSize > maxWarningHeaderSize) { // if max size has already been reached before
final String message = "Dropping a warning header, as their total size reached the maximum allowed of [" +
maxWarningHeaderSize + "] bytes set in [" +
HttpTransportSettings.SETTING_HTTP_MAX_WARNING_HEADER_SIZE.getKey() + "]!";
ESLoggerFactory.getLogger(ThreadContext.class).warn(message);
logger.warn("Dropping a warning header, as their total size reached the maximum allowed of ["
+ maxWarningHeaderSize + "] bytes set in ["
+ HttpTransportSettings.SETTING_HTTP_MAX_WARNING_HEADER_SIZE.getKey() + "]!");
return this;
}
newWarningHeaderSize += "Warning".getBytes(StandardCharsets.UTF_8).length + value.getBytes(StandardCharsets.UTF_8).length;
if (newWarningHeaderSize > maxWarningHeaderSize) {
final String message = "Dropping a warning header, as their total size reached the maximum allowed of [" +
maxWarningHeaderSize + "] bytes set in [" +
HttpTransportSettings.SETTING_HTTP_MAX_WARNING_HEADER_SIZE.getKey() + "]!";
ESLoggerFactory.getLogger(ThreadContext.class).warn(message);
logger.warn("Dropping a warning header, as their total size reached the maximum allowed of ["
+ maxWarningHeaderSize + "] bytes set in ["
+ HttpTransportSettings.SETTING_HTTP_MAX_WARNING_HEADER_SIZE.getKey() + "]!");
return new ThreadContextStruct(requestHeaders, responseHeaders, transientHeaders, isSystemContext, newWarningHeaderSize);
}
}
@ -505,9 +505,9 @@ public final class ThreadContext implements Closeable, Writeable {
if ((key.equals("Warning")) && (maxWarningHeaderCount != -1)) { //if count is NOT unbounded, check its limits
final int warningHeaderCount = newResponseHeaders.containsKey("Warning") ? newResponseHeaders.get("Warning").size() : 0;
if (warningHeaderCount > maxWarningHeaderCount) {
final String message = "Dropping a warning header, as their total count reached the maximum allowed of [" +
maxWarningHeaderCount + "] set in [" + HttpTransportSettings.SETTING_HTTP_MAX_WARNING_HEADER_COUNT.getKey() + "]!";
ESLoggerFactory.getLogger(ThreadContext.class).warn(message);
logger.warn("Dropping a warning header, as their total count reached the maximum allowed of ["
+ maxWarningHeaderCount + "] set in ["
+ HttpTransportSettings.SETTING_HTTP_MAX_WARNING_HEADER_COUNT.getKey() + "]!");
return this;
}
}
@ -641,7 +641,7 @@ public final class ThreadContext implements Closeable, Writeable {
assert e instanceof CancellationException
|| e instanceof InterruptedException
|| e instanceof ExecutionException : e;
final Optional<Error> maybeError = ExceptionsHelper.maybeError(e, ESLoggerFactory.getLogger(ThreadContext.class));
final Optional<Error> maybeError = ExceptionsHelper.maybeError(e, logger);
if (maybeError.isPresent()) {
// throw this error where it will propagate to the uncaught exception handler
throw maybeError.get();

View File

@ -19,13 +19,13 @@
package org.elasticsearch.index.mapper;
import org.apache.logging.log4j.LogManager;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.search.Query;
import org.elasticsearch.Version;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.lucene.Lucene;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
@ -49,7 +49,7 @@ import java.util.Objects;
public class FieldNamesFieldMapper extends MetadataFieldMapper {
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(
ESLoggerFactory.getLogger(FieldNamesFieldMapper.class));
LogManager.getLogger(FieldNamesFieldMapper.class));
public static final String NAME = "_field_names";

View File

@ -19,6 +19,7 @@
package org.elasticsearch.index.mapper;
import org.apache.logging.log4j.LogManager;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
@ -27,7 +28,6 @@ import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.collect.CopyOnWriteHashMap;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
@ -45,7 +45,7 @@ import java.util.Locale;
import java.util.Map;
public class ObjectMapper extends Mapper implements Cloneable {
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(ESLoggerFactory.getLogger(ObjectMapper.class));
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(ObjectMapper.class));
public static final String CONTENT_TYPE = "object";
public static final String NESTED_CONTENT_TYPE = "nested";

View File

@ -19,6 +19,7 @@
package org.elasticsearch.index.mapper;
import org.apache.logging.log4j.LogManager;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.SortedSetDocValuesField;
import org.apache.lucene.index.IndexOptions;
@ -36,7 +37,6 @@ import org.apache.lucene.search.TermInSetQuery;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.lucene.Lucene;
import org.elasticsearch.common.lucene.search.Queries;
import org.elasticsearch.common.xcontent.XContentBuilder;
@ -92,7 +92,7 @@ public class TypeFieldMapper extends MetadataFieldMapper {
static final class TypeFieldType extends StringFieldType {
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(ESLoggerFactory.getLogger(TypeFieldType.class));
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(LogManager.getLogger(TypeFieldType.class));
TypeFieldType() {
}

View File

@ -20,10 +20,10 @@
package org.elasticsearch.monitor.os;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.lucene.util.Constants;
import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.io.PathUtils;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.monitor.Probes;
import java.io.IOException;
@ -517,7 +517,7 @@ public class OsProbe {
}
private final Logger logger = ESLoggerFactory.getLogger(getClass());
private final Logger logger = LogManager.getLogger(getClass());
public OsInfo osInfo(long refreshInterval, int allocatedProcessors) {
return new OsInfo(refreshInterval, Runtime.getRuntime().availableProcessors(),

View File

@ -20,6 +20,7 @@
package org.elasticsearch.plugins;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.lucene.analysis.util.CharFilterFactory;
import org.apache.lucene.analysis.util.TokenFilterFactory;
import org.apache.lucene.analysis.util.TokenizerFactory;
@ -36,7 +37,6 @@ import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.component.LifecycleComponent;
import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.io.FileSystemUtils;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property;
@ -475,7 +475,7 @@ public class PluginsService extends AbstractComponent {
List<String> exts = bundle.plugin.getExtendedPlugins();
try {
final Logger logger = ESLoggerFactory.getLogger(JarHell.class);
final Logger logger = LogManager.getLogger(JarHell.class);
Set<URL> urls = new HashSet<>();
for (String extendedPlugin : exts) {
Set<URL> pluginUrls = transitiveUrls.get(extendedPlugin);

View File

@ -19,9 +19,9 @@
package org.elasticsearch.script;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
@ -48,7 +48,7 @@ import java.util.Locale;
*/
public class JodaCompatibleZonedDateTime {
private static final DeprecationLogger DEPRECATION_LOGGER =
new DeprecationLogger(ESLoggerFactory.getLogger(JodaCompatibleZonedDateTime.class));
new DeprecationLogger(LogManager.getLogger(JodaCompatibleZonedDateTime.class));
private static void logDeprecated(String key, String message, Object... params) {
// NOTE: we don't check SpecialPermission because this will be called (indirectly) from scripts

View File

@ -22,13 +22,13 @@ package org.elasticsearch.bootstrap;
import com.carrotsearch.randomizedtesting.RandomizedRunner;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.common.Booleans;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.io.FileSystemUtils;
import org.elasticsearch.common.io.PathUtils;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.network.IfConfig;
import org.elasticsearch.plugins.PluginInfo;
import org.elasticsearch.secure_sm.SecureSM;
@ -90,7 +90,7 @@ public class BootstrapForTesting {
// check for jar hell
try {
final Logger logger = ESLoggerFactory.getLogger(JarHell.class);
final Logger logger = LogManager.getLogger(JarHell.class);
JarHell.checkJarHell(logger::debug);
} catch (Exception e) {
throw new RuntimeException("found jar hell in test classpath", e);

View File

@ -6,6 +6,7 @@
package org.elasticsearch.xpack.core;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.lucene.util.SetOnce;
import org.elasticsearch.SpecialPermission;
import org.elasticsearch.Version;
@ -28,7 +29,6 @@ import org.elasticsearch.common.inject.multibindings.Multibinder;
import org.elasticsearch.common.inject.util.Providers;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.IndexScopedSettings;
import org.elasticsearch.common.settings.Setting;
@ -84,7 +84,7 @@ import java.util.stream.StreamSupport;
public class XPackPlugin extends XPackClientPlugin implements ScriptPlugin, ExtensiblePlugin, RepositoryPlugin, EnginePlugin {
private static Logger logger = ESLoggerFactory.getLogger(XPackPlugin.class);
private static Logger logger = LogManager.getLogger(XPackPlugin.class);
private static DeprecationLogger deprecationLogger = new DeprecationLogger(logger);
public static final String XPACK_INSTALLED_NODE_ATTR = "xpack.installed";

View File

@ -11,12 +11,12 @@ import com.sun.net.httpserver.HttpsConfigurator;
import com.sun.net.httpserver.HttpsParameters;
import com.sun.net.httpserver.HttpsServer;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.logging.log4j.util.Supplier;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.io.Streams;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
import org.elasticsearch.mocksocket.MockHttpServer;
@ -73,7 +73,7 @@ public class MockWebServer implements Closeable {
*/
public MockWebServer(SSLContext sslContext, boolean needClientAuth) {
this.needClientAuth = needClientAuth;
this.logger = ESLoggerFactory.getLogger(this.getClass());
this.logger = LogManager.getLogger(this.getClass());
this.sslContext = sslContext;
}

View File

@ -9,8 +9,8 @@ import joptsimple.OptionParser;
import joptsimple.OptionSet;
import joptsimple.OptionSpec;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.LoggerContext;
@ -26,7 +26,6 @@ import org.elasticsearch.cli.Terminal.Verbosity;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
@ -360,7 +359,7 @@ public class ESNativeRealmMigrateTool extends LoggingAwareMultiCommand {
* Creates a new Logger that is detached from the ROOT logger and only has an appender that will output log messages to the terminal
*/
static Logger getTerminalLogger(final Terminal terminal) {
final Logger logger = ESLoggerFactory.getLogger(ESNativeRealmMigrateTool.class);
final Logger logger = LogManager.getLogger(ESNativeRealmMigrateTool.class);
Loggers.setLevel(logger, Level.ALL);
final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);

View File

@ -7,10 +7,10 @@
package org.elasticsearch.xpack.security.authc.kerberos;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.ietf.jgss.GSSContext;
import org.ietf.jgss.GSSCredential;
import org.ietf.jgss.GSSException;
@ -53,7 +53,7 @@ public class KerberosTicketValidator {
return oid;
}
private static final Logger LOGGER = ESLoggerFactory.getLogger(KerberosTicketValidator.class);
private static final Logger LOGGER = LogManager.getLogger(KerberosTicketValidator.class);
private static final String KEY_TAB_CONF_NAME = "KeytabConf";
private static final String SUN_KRB5_LOGIN_MODULE = "com.sun.security.auth.module.Krb5LoginModule";

View File

@ -23,6 +23,7 @@ import com.unboundid.ldap.sdk.SearchResultEntry;
import com.unboundid.ldap.sdk.SearchResultReference;
import com.unboundid.ldap.sdk.SearchScope;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.logging.log4j.util.Supplier;
import org.elasticsearch.core.internal.io.IOUtils;
@ -32,7 +33,6 @@ import org.elasticsearch.action.ActionListener;
import org.elasticsearch.common.CheckedSupplier;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
import org.elasticsearch.common.util.concurrent.CountDown;
import org.elasticsearch.threadpool.ThreadPool;
@ -55,7 +55,7 @@ public final class LdapUtils {
public static final Filter OBJECT_CLASS_PRESENCE_FILTER = Filter.createPresenceFilter("objectClass");
private static final Logger LOGGER = ESLoggerFactory.getLogger(LdapUtils.class);
private static final Logger LOGGER = LogManager.getLogger(LdapUtils.class);
private LdapUtils() {
}

View File

@ -37,12 +37,12 @@ import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.core.internal.io.IOUtils;
import org.elasticsearch.ElasticsearchSecurityException;
import org.elasticsearch.SpecialPermission;
import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.hash.MessageDigests;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.xpack.security.support.RestorableContextClassLoader;
import org.opensaml.core.config.InitializationService;
import org.opensaml.core.xml.XMLObject;
@ -71,7 +71,7 @@ public class SamlUtils {
private static final SecureRandom SECURE_RANDOM = new SecureRandom();
private static XMLObjectBuilderFactory builderFactory = null;
private static final Logger LOGGER = ESLoggerFactory.getLogger(SamlUtils.class);
private static final Logger LOGGER = LogManager.getLogger(SamlUtils.class);
/**
* This is needed in order to initialize the underlying OpenSAML library.

View File

@ -6,11 +6,11 @@
package org.elasticsearch.xpack.security.rest;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.logging.log4j.util.Supplier;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.http.HttpChannel;
import org.elasticsearch.license.XPackLicenseState;
@ -27,7 +27,7 @@ import java.io.IOException;
public class SecurityRestFilter implements RestHandler {
private static final Logger logger = ESLoggerFactory.getLogger(SecurityRestFilter.class);
private static final Logger logger = LogManager.getLogger(SecurityRestFilter.class);
private final RestHandler restHandler;
private final AuthenticationService service;

View File

@ -8,7 +8,6 @@ package org.elasticsearch.xpack.watcher.notification.jira;
import org.elasticsearch.common.Booleans;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.settings.SecureSetting;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Setting;
@ -64,7 +63,6 @@ public class JiraAccount {
this.httpClient = httpClient;
this.name = name;
String url = getSetting(name, URL_SETTING, settings, SECURE_URL_SETTING);
ESLoggerFactory.getLogger(getClass()).error("THE URL WAS [{}]", url);
try {
URI uri = new URI(url);
Scheme protocol = Scheme.parse(uri.getScheme());

View File

@ -7,9 +7,9 @@
package org.elasticsearch.xpack.security.authc.kerberos;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.xpack.security.authc.kerberos.KerberosTicketValidator;
import org.ietf.jgss.GSSContext;
@ -50,7 +50,7 @@ import javax.security.auth.login.LoginException;
* {@link GSSContext} after usage.
*/
class SpnegoClient implements AutoCloseable {
private static final Logger LOGGER = ESLoggerFactory.getLogger(SpnegoClient.class);
private static final Logger LOGGER = LogManager.getLogger(SpnegoClient.class);
public static final String CRED_CONF_NAME = "PasswordConf";
private static final String SUN_KRB5_LOGIN_MODULE = "com.sun.security.auth.module.Krb5LoginModule";