Skip to content

Commit

Permalink
[7.x] Add category field to deprecation logs (#77550)
Browse files Browse the repository at this point in the history
Deprecation logs in 7.x are using ESJsonLayout and it requires
additional fields to be declared in a log4j config in order to emit
values to logs.
This commit adds category field to deprecation log pattern

context: in 8.0 we use ECSLayout which do not require to declare additional fields upfront. In 7.x we have to declare them in the logging config. The PR introducing categories in master #67443. A backport to 7.x which missed this field #68061
  • Loading branch information
pgomulka authored Oct 18, 2021
1 parent 322a5c3 commit b7968e6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion distribution/src/config/log4j2.properties
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ appender.deprecation_rolling.name = deprecation_rolling
appender.deprecation_rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_deprecation.json
appender.deprecation_rolling.layout.type = ESJsonLayout
appender.deprecation_rolling.layout.type_name = deprecation.elasticsearch
appender.deprecation_rolling.layout.esmessagefields=x-opaque-id,key
appender.deprecation_rolling.layout.esmessagefields=x-opaque-id,key,category
appender.deprecation_rolling.filter.rate_limit.type = RateLimitingFilter

appender.deprecation_rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_deprecation-%i.json.gz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public void testParseFieldEmittingDeprecatedLogs() throws Exception {
allOf(
hasEntry("type", "deprecation.elasticsearch"),
hasEntry("level", "CRITICAL"),
hasEntry("category", "api"),
hasEntry("component", "o.e.d.x.ParseField"),
hasEntry("cluster.name", "elasticsearch"),
hasEntry("node.name", "sample-name"),
Expand All @@ -161,6 +162,7 @@ public void testParseFieldEmittingDeprecatedLogs() throws Exception {
allOf(
hasEntry("type", "deprecation.elasticsearch"),
hasEntry("level", "CRITICAL"),
hasEntry("category", "api"),
hasEntry("component", "o.e.d.x.ParseField"),
hasEntry("cluster.name", "elasticsearch"),
hasEntry("node.name", "sample-name"),
Expand Down Expand Up @@ -200,6 +202,7 @@ public void testDeprecatedMessage() throws Exception {
allOf(
hasEntry("type", "deprecation.elasticsearch"),
hasEntry("level", "CRITICAL"),
hasEntry("category", "other"),
hasEntry("component", "o.e.d.test"),
hasEntry("cluster.name", "elasticsearch"),
hasEntry("node.name", "sample-name"),
Expand Down Expand Up @@ -347,6 +350,7 @@ public void testDuplicateLogMessages() throws Exception {
allOf(
hasEntry("type", "deprecation.elasticsearch"),
hasEntry("level", "CRITICAL"),
hasEntry("category", "other"),
hasEntry("component", "o.e.d.test"),
hasEntry("cluster.name", "elasticsearch"),
hasEntry("node.name", "sample-name"),
Expand Down Expand Up @@ -381,6 +385,7 @@ public void testDuplicateLogMessages() throws Exception {
allOf(
hasEntry("type", "deprecation.elasticsearch"),
hasEntry("level", "CRITICAL"),
hasEntry("category", "other"),
hasEntry("component", "o.e.d.test"),
hasEntry("cluster.name", "elasticsearch"),
hasEntry("node.name", "sample-name"),
Expand All @@ -390,6 +395,7 @@ public void testDuplicateLogMessages() throws Exception {
allOf(
hasEntry("type", "deprecation.elasticsearch"),
hasEntry("level", "CRITICAL"),
hasEntry("category", "other"),
hasEntry("component", "o.e.d.test"),
hasEntry("cluster.name", "elasticsearch"),
hasEntry("node.name", "sample-name"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ appender.deprecated.name = deprecated
appender.deprecated.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_deprecated.json
appender.deprecated.layout.type = ESJsonLayout
appender.deprecated.layout.type_name = deprecation.elasticsearch
appender.deprecated.layout.esmessagefields = x-opaque-id,key
appender.deprecated.layout.esmessagefields = x-opaque-id,key,category
appender.deprecated.filter.rate_limit.type = RateLimitingFilter

appender.deprecation_rolling_old.type = File
Expand All @@ -28,7 +28,7 @@ appender.deprecatedconsole.type = Console
appender.deprecatedconsole.name = deprecatedconsole
appender.deprecatedconsole.layout.type = ESJsonLayout
appender.deprecatedconsole.layout.type_name = deprecation.elasticsearch
appender.deprecatedconsole.layout.esmessagefields = x-opaque-id,key
appender.deprecatedconsole.layout.esmessagefields = x-opaque-id,key,category
appender.deprecatedconsole.filter.rate_limit.type = RateLimitingFilter

appender.index_search_slowlog_rolling.type = File
Expand Down

0 comments on commit b7968e6

Please sign in to comment.