Skip to content

Commit

Permalink
Change default deprecation logger level to CRITICAL backport(#77030) (#…
Browse files Browse the repository at this point in the history
…77482)

This commit changes default deprecation logger level to CRITICAL, where default means deprecations emitted by DeprecationLogger#critical method.
It also introduces WARN deprecations which are emitted by DeprecationLogger#warn Those log lines emitted at WARN are meant to indicate that a functionality is deprecated but will not break at next major version.
relates #76754
  • Loading branch information
pgomulka committed Sep 27, 2021
1 parent 6cccbf5 commit 4ef3a58
Show file tree
Hide file tree
Showing 195 changed files with 509 additions and 365 deletions.
2 changes: 1 addition & 1 deletion distribution/src/config/log4j2.properties
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ appender.deprecation_rolling_old.strategy.type = DefaultRolloverStrategy
appender.deprecation_rolling_old.strategy.max = 4
#################################################
logger.deprecation.name = org.elasticsearch.deprecation
logger.deprecation.level = deprecation
logger.deprecation.level = WARN
logger.deprecation.appenderRef.deprecation_rolling.ref = deprecation_rolling
logger.deprecation.appenderRef.deprecation_rolling_old.ref = deprecation_rolling_old
logger.deprecation.appenderRef.header_warning.ref = header_warning
Expand Down
6 changes: 3 additions & 3 deletions docs/reference/setup/logging-config.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ By default, {es} rolls and compresses deprecation logs at 1GB. The default
configuration preserves a maximum of five log files: four rolled logs and an
active log.

{es} emits deprecation log messages at the `DEPRECATION` level. To stop writing
deprecation log messages, set `logger.deprecation.level` to `error`:
{es} emits deprecation log messages at the `CRITICAL` level. To stop writing
deprecation log messages, set `logger.deprecation.level` to `OFF`:

[source,properties]
----
logger.deprecation.level = error
logger.deprecation.level = OFF
----

You can identify what is triggering deprecated functionality if `X-Opaque-Id` was used as an HTTP header.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public TokenFilterFactory getSynonymFilter() {
"] cannot be used to parse synonyms");
}
else {
DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters", "Token filter [" + name()
DEPRECATION_LOGGER.critical(DeprecationCategory.ANALYSIS, "synonym_tokenfilters", "Token filter [" + name()
+ "] will not be usable to parse synonyms after v7.0");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public Map<String, AnalysisProvider<TokenFilterFactory>> getTokenFilters() {
filters.put("dutch_stem", DutchStemTokenFilterFactory::new);
filters.put("edge_ngram", EdgeNGramTokenFilterFactory::new);
filters.put("edgeNGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "edgeNGram_deprecation",
deprecationLogger.critical(DeprecationCategory.ANALYSIS, "edgeNGram_deprecation",
"The [edgeNGram] token filter name is deprecated and will be removed in a future version. "
+ "Please change the filter name to [edge_ngram] instead.");
return new EdgeNGramTokenFilterFactory(indexSettings, environment, name, settings);
Expand All @@ -264,7 +264,7 @@ public Map<String, AnalysisProvider<TokenFilterFactory>> getTokenFilters() {
filters.put("multiplexer", MultiplexerTokenFilterFactory::new);
filters.put("ngram", NGramTokenFilterFactory::new);
filters.put("nGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "nGram_deprecation",
deprecationLogger.critical(DeprecationCategory.ANALYSIS, "nGram_deprecation",
"The [nGram] token filter name is deprecated and will be removed in a future version. "
+ "Please change the filter name to [ngram] instead.");
return new NGramTokenFilterFactory(indexSettings, environment, name, settings);
Expand Down Expand Up @@ -313,7 +313,7 @@ public Map<String, AnalysisProvider<TokenizerFactory>> getTokenizers() {
tokenizers.put("thai", ThaiTokenizerFactory::new);
tokenizers.put("nGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> {
if (indexSettings.getIndexVersionCreated().onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "nGram_tokenizer_deprecation",
deprecationLogger.critical(DeprecationCategory.ANALYSIS, "nGram_tokenizer_deprecation",
"The [nGram] tokenizer name is deprecated and will be removed in a future version. "
+ "Please change the tokenizer name to [ngram] instead.");
}
Expand All @@ -322,7 +322,7 @@ public Map<String, AnalysisProvider<TokenizerFactory>> getTokenizers() {
tokenizers.put("ngram", NGramTokenizerFactory::new);
tokenizers.put("edgeNGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> {
if (indexSettings.getIndexVersionCreated().onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "edgeNGram_tokenizer_deprecation",
deprecationLogger.critical(DeprecationCategory.ANALYSIS, "edgeNGram_tokenizer_deprecation",
"The [edgeNGram] tokenizer name is deprecated and will be removed in a future version. "
+ "Please change the tokenizer name to [edge_ngram] instead.");
}
Expand Down Expand Up @@ -403,7 +403,7 @@ public List<PreConfiguredCharFilter> getPreConfiguredCharFilters() {
filters.add(PreConfiguredCharFilter.singleton("html_strip", false, HTMLStripCharFilter::new));
filters.add(PreConfiguredCharFilter.elasticsearchVersion("htmlStrip", false, (reader, version) -> {
if (version.onOrAfter(org.elasticsearch.Version.V_6_3_0)) {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "htmlStrip_deprecation",
deprecationLogger.critical(DeprecationCategory.ANALYSIS, "htmlStrip_deprecation",
"The [htmpStrip] char filter name is deprecated and will be removed in a future version. "
+ "Please change the filter name to [html_strip] instead.");
}
Expand Down Expand Up @@ -434,7 +434,7 @@ public List<PreConfiguredTokenFilter> getPreConfiguredTokenFilters() {
"[delimited_payload_filter] is not supported for new indices, use [delimited_payload] instead");
}
if (version.onOrAfter(Version.V_6_2_0)) {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "analysis_delimited_payload_filter",
deprecationLogger.critical(DeprecationCategory.ANALYSIS, "analysis_delimited_payload_filter",
"Deprecated [delimited_payload_filter] used, replaced by [delimited_payload]");
}
return new DelimitedPayloadTokenFilter(input,
Expand All @@ -454,7 +454,7 @@ public List<PreConfiguredTokenFilter> getPreConfiguredTokenFilters() {
"The [edgeNGram] token filter name was deprecated in 6.4 and cannot be used in new indices. "
+ "Please change the filter name to [edge_ngram] instead.");
} else {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "edgeNGram_deprecation",
deprecationLogger.critical(DeprecationCategory.ANALYSIS, "edgeNGram_deprecation",
"The [edgeNGram] token filter name is deprecated and will be removed in a future version. "
+ "Please change the filter name to [edge_ngram] instead.");
}
Expand All @@ -481,7 +481,7 @@ public List<PreConfiguredTokenFilter> getPreConfiguredTokenFilters() {
throw new IllegalArgumentException("The [nGram] token filter name was deprecated in 6.4 and cannot be used in new indices. "
+ "Please change the filter name to [ngram] instead.");
} else {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "nGram_deprecation",
deprecationLogger.critical(DeprecationCategory.ANALYSIS, "nGram_deprecation",
"The [nGram] token filter name is deprecated and will be removed in a future version. "
+ "Please change the filter name to [ngram] instead.");
}
Expand Down Expand Up @@ -559,15 +559,15 @@ public List<PreConfiguredTokenizer> getPreConfiguredTokenizers() {
// Temporary shim for aliases. TODO deprecate after they are moved
tokenizers.add(PreConfiguredTokenizer.elasticsearchVersion("nGram", (version) -> {
if (version.onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "nGram_tokenizer_deprecation",
deprecationLogger.critical(DeprecationCategory.ANALYSIS, "nGram_tokenizer_deprecation",
"The [nGram] tokenizer name is deprecated and will be removed in a future version. "
+ "Please change the tokenizer name to [ngram] instead.");
}
return new NGramTokenizer();
}));
tokenizers.add(PreConfiguredTokenizer.elasticsearchVersion("edgeNGram", (version) -> {
if (version.onOrAfter(org.elasticsearch.Version.V_7_6_0)) {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "edgeNGram_tokenizer_deprecation",
deprecationLogger.critical(DeprecationCategory.ANALYSIS, "edgeNGram_tokenizer_deprecation",
"The [edgeNGram] tokenizer name is deprecated and will be removed in a future version. "
+ "Please change the tokenizer name to [edge_ngram] instead.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public TokenFilterFactory getSynonymFilter() {
if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) {
throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms");
} else {
DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters", "Token filter [" + name()
DEPRECATION_LOGGER.critical(DeprecationCategory.ANALYSIS, "synonym_tokenfilters", "Token filter [" + name()
+ "] will not be usable to parse synonyms after v7.0");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public TokenFilterFactory getSynonymFilter() {
throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms");
}
else {
DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters",
DEPRECATION_LOGGER.critical(DeprecationCategory.ANALYSIS, "synonym_tokenfilters",
"Token filter [" + name() + "] will not be usable to parse synonyms after v7.0");
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public TokenFilterFactory getSynonymFilter() {
throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms");
}
else {
DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters", "Token filter [" + name()
DEPRECATION_LOGGER.critical(DeprecationCategory.ANALYSIS, "synonym_tokenfilters", "Token filter [" + name()
+ "] will not be usable to parse synonyms after v7.0");
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class LegacyDelimitedPayloadTokenFilterFactory extends DelimitedPayloadTo
"[delimited_payload_filter] is not supported for new indices, use [delimited_payload] instead");
}
if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_6_2_0)) {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "analysis_legacy_delimited_payload_filter",
deprecationLogger.critical(DeprecationCategory.ANALYSIS, "analysis_legacy_delimited_payload_filter",
"Deprecated [delimited_payload_filter] used, replaced by [delimited_payload]");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public TokenFilterFactory getSynonymFilter() {
}
else {
if (preserveOriginal) {
DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters",
DEPRECATION_LOGGER.critical(DeprecationCategory.ANALYSIS, "synonym_tokenfilters",
"Token filter [" + name() + "] will not be usable to parse synonyms after v7.0");
return IDENTITY_FILTER;
}
Expand Down Expand Up @@ -119,7 +119,7 @@ public TokenFilterFactory getSynonymFilter() {
}
else {
if (preserveOriginal) {
DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters",
DEPRECATION_LOGGER.critical(DeprecationCategory.ANALYSIS, "synonym_tokenfilters",
"Token filter [" + name() + "] will not be usable to parse synonyms after v7.0");
return IDENTITY_FILTER;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class NGramTokenFilterFactory extends AbstractTokenFilterFactory {
+ maxAllowedNgramDiff + "] but was [" + ngramDiff + "]. This limit can be set by changing the ["
+ IndexSettings.MAX_NGRAM_DIFF_SETTING.getKey() + "] index level setting.");
} else {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "ngram_big_difference",
deprecationLogger.critical(DeprecationCategory.ANALYSIS, "ngram_big_difference",
"Deprecated big difference between max_gram and min_gram in NGram Tokenizer,"
+ "expected difference must be less than or equal to: [" + maxAllowedNgramDiff + "]");
}
Expand All @@ -61,7 +61,7 @@ public TokenFilterFactory getSynonymFilter() {
throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms");
}
else {
DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters",
DEPRECATION_LOGGER.critical(DeprecationCategory.ANALYSIS, "synonym_tokenfilters",
"Token filter [" + name() + "] will not be usable to parse synonyms after v7.0");
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public boolean isTokenChar(int c) {
+ maxAllowedNgramDiff + "] but was [" + ngramDiff + "]. This limit can be set by changing the ["
+ IndexSettings.MAX_NGRAM_DIFF_SETTING.getKey() + "] index level setting.");
} else {
deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "ngram_big_difference",
deprecationLogger.critical(DeprecationCategory.ANALYSIS, "ngram_big_difference",
"Deprecated big difference between max_gram and min_gram in NGram Tokenizer,"
+ "expected difference must be less than or equal to: [" + maxAllowedNgramDiff + "]");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class StandardHtmlStripAnalyzerProvider extends AbstractIndexAnalyzerProv
throw new IllegalArgumentException("[standard_html_strip] analyzer is not supported for new indices, " +
"use a custom analyzer using [standard] tokenizer and [html_strip] char_filter, plus [lowercase] filter");
} else {
DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "standard_html_strip_deprecation",
DEPRECATION_LOGGER.critical(DeprecationCategory.ANALYSIS, "standard_html_strip_deprecation",
"Deprecated analyzer [standard_html_strip] used, " +
"replace it with a custom analyzer using [standard] tokenizer and [html_strip] char_filter, plus [lowercase] filter");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class SynonymTokenFilterFactory extends AbstractTokenFilterFactory {
this.settings = settings;

if (settings.get("ignore_case") != null) {
DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_ignore_case_option",
DEPRECATION_LOGGER.critical(DeprecationCategory.ANALYSIS, "synonym_ignore_case_option",
"The ignore_case option on the synonym_graph filter is deprecated. " +
"Instead, insert a lowercase filter in the filter chain before the synonym_graph filter.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public TokenFilterFactory getSynonymFilter() {
throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms");
}
else {
DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters",
DEPRECATION_LOGGER.critical(DeprecationCategory.ANALYSIS, "synonym_tokenfilters",
"Token filter [" + name() + "] will not be usable to parse synonyms after v7.0");
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public TokenFilterFactory getSynonymFilter() {
throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms");
}
else {
DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters",
DEPRECATION_LOGGER.critical(DeprecationCategory.ANALYSIS, "synonym_tokenfilters",
"Token filter [" + name() + "] will not be usable to parse synonyms after v7.0");
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public final class ScriptProcessor extends AbstractProcessor {
DeprecationLogger.getLogger(DynamicMap.class);
private static final Map<String, Function<Object, Object>> PARAMS_FUNCTIONS = org.elasticsearch.core.Map.of(
"_type", value -> {
deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "script_processor",
deprecationLogger.critical(DeprecationCategory.SCRIPTING, "script_processor",
"[types removal] Looking up doc types [_type] in scripts is deprecated.");
return value;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public UserAgentProcessor create(Map<String, Processor.Factory> factories, Strin
}

if (useECS == false) {
deprecationLogger.deprecate(DeprecationCategory.SETTINGS, "ecs_false_non_common_schema",
deprecationLogger.critical(DeprecationCategory.SETTINGS, "ecs_false_non_common_schema",
"setting [ecs] to false for non-common schema " +
"format is deprecated and will be removed in 8.0, set to true or remove to use the non-deprecated format");
}
Expand Down Expand Up @@ -383,7 +383,7 @@ public static Property parseProperty(String propertyName) {
Property value = valueOf(propertyName.toUpperCase(Locale.ROOT));
if (DEPRECATED_PROPERTIES.contains(value)) {
final String key = "user_agent_processor_property_" + propertyName.replaceAll("[^\\w_]+", "_");
deprecationLogger.deprecate(DeprecationCategory.PARSING, key,
deprecationLogger.critical(DeprecationCategory.PARSING, key,
"the [{}] property is deprecated for the user-agent processor", propertyName);
}
return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client
// Emit a single deprecation message if any search template contains types.
for (SearchTemplateRequest searchTemplateRequest : multiRequest.requests()) {
if (searchTemplateRequest.getRequest().types().length > 0) {
deprecationLogger.deprecate(DeprecationCategory.TYPES, "msearch_with_types", TYPES_DEPRECATION_MESSAGE);
deprecationLogger.critical(DeprecationCategory.TYPES, "msearch_with_types", TYPES_DEPRECATION_MESSAGE);
break;
}
}
Expand Down

0 comments on commit 4ef3a58

Please sign in to comment.