Package org.elasticsearch.common.logging
Class DeprecationLogger
java.lang.Object
org.elasticsearch.common.logging.DeprecationLogger
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
FieldsModifier and TypeFieldDescriptionstatic org.apache.logging.log4j.LevelDeprecation messages are logged at this level. -
Method Summary
Modifier and TypeMethodDescriptiondeprecate(DeprecationCategory category, String key, String msg, Object... params)Logs a message at theDEPRECATIONlevel.static DeprecationLoggerCreates a new deprecation logger for the supplied class.static DeprecationLoggerCreates a new deprecation logger based on the parent logger.
-
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, String key, String msg, 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.
-