Package org.elasticsearch.common.logging
Class DeprecationLogger
java.lang.Object
org.elasticsearch.common.logging.DeprecationLogger
public class DeprecationLogger
extends java.lang.Object
A logger that logs deprecation notices. Logger should be initialized with a parent logger which name will be used
for deprecation logger. For instance
DeprecationLogger.getLogger("org.elasticsearch.test.SomeClass") will
result in a deprecation logger with name org.elasticsearch.deprecation.test.SomeClass. This allows to use a
deprecation logger defined in log4j2.properties.
Logs are emitted at the custom DEPRECATION level, and routed wherever they need to go using log4j. For example,
to disk using a rolling file appender, or added as a response header using HeaderWarningAppender.
Deprecation messages include a key, which is used for rate-limiting purposes. The log4j configuration
uses RateLimitingFilter to prevent the same message being logged repeatedly in a short span of time. This
key is combined with the X-Opaque-Id request header value, if supplied, which allows for per-client
message limiting.
-
Field Summary
Fields Modifier and Type Field Description static org.apache.logging.log4j.LevelDEPRECATIONDeprecation messages are logged at this level. -
Method Summary
Modifier and Type Method Description DeprecationLoggerdeprecate(DeprecationCategory category, java.lang.String key, java.lang.String msg, java.lang.Object... params)Logs a message at theDEPRECATIONlevel.static DeprecationLoggergetLogger(java.lang.Class<?> aClass)Creates a new deprecation logger for the supplied class.static DeprecationLoggergetLogger(java.lang.String name)Creates a new deprecation logger based on the parent logger.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
DEPRECATION
public static org.apache.logging.log4j.Level DEPRECATIONDeprecation messages are logged at this level.
-
-
Method Details
-
getLogger
Creates a new deprecation logger for the supplied class. Internally, it delegates togetLogger(String), passing the full class name. -
getLogger
Creates a new deprecation logger based on the parent logger. Automatically prefixes the logger name with "deprecation", if it starts with "org.elasticsearch.", it replaces "org.elasticsearch" with "org.elasticsearch.deprecation" to maintain the "org.elasticsearch" namespace. -
deprecate
public DeprecationLogger deprecate(DeprecationCategory category, java.lang.String key, java.lang.String msg, java.lang.Object... params)Logs a message at theDEPRECATIONlevel. The message is also sent to the header warning logger, so that it can be returned to the client.
-