Skip to content

Commit

Permalink
Renamed setting from log.format.json_strict to log.format.json.fix_du…
Browse files Browse the repository at this point in the history
…plicate_message_fields
  • Loading branch information
andsel committed Apr 12, 2024
1 parent 0f108de commit 9237560
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docker/data/logstash/env2yaml/env2yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func normalizeSetting(setting string) (string, error) {
"http.port", // DEPRECATED: prefer `api.http.port`
"log.level",
"log.format",
"log.format.json_strict",
"log.format.json.fix_duplicate_message_fields",
"modules",
"metric.collect",
"path.logs",
Expand Down
4 changes: 2 additions & 2 deletions docs/static/troubleshoot/ts-logstash.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,12 @@ In `config/logstash.yml` enable the strict json flag:

[source,yaml]
-----
log.format.json_strict: true
log.format.json.fix_duplicate_message_fields: true
-----

or pass the command line switch

[source]
-----
bin/logstash --log.format.json_strict true
bin/logstash --log.format.json.fix_duplicate_message_fields true
-----
4 changes: 2 additions & 2 deletions logstash-core/lib/logstash/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module Environment
Setting::Boolean.new("help", false),
Setting::Boolean.new("enable-local-plugin-development", false),
Setting::String.new("log.format", "plain", true, ["json", "plain"]),
Setting::Boolean.new("log.format.json_strict", false),
Setting::Boolean.new("log.format.json.fix_duplicate_message_fields", false),
Setting::Boolean.new("api.enabled", true).with_deprecated_alias("http.enabled"),
Setting::String.new("api.http.host", "127.0.0.1").with_deprecated_alias("http.host"),
Setting::PortRange.new("api.http.port", 9600..9700).with_deprecated_alias("http.port"),
Expand Down Expand Up @@ -124,7 +124,7 @@ module Environment
SETTINGS.on_post_process do |settings|
# Configure Logstash logging facility. This needs to be done as early as possible to
# make sure the logger has the correct settings tnd the log level is correctly defined.
java.lang.System.setProperty("ls.log.json.strict", settings.get("log.format.json_strict").to_s)
java.lang.System.setProperty("ls.log.format.json.fix_duplicate_message_fields", settings.get("log.format.json.fix_duplicate_message_fields").to_s)
java.lang.System.setProperty("ls.logs", settings.get("path.logs"))
java.lang.System.setProperty("ls.log.format", settings.get("log.format"))
java.lang.System.setProperty("ls.log.level", settings.get("log.level"))
Expand Down
8 changes: 4 additions & 4 deletions logstash-core/lib/logstash/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ class LogStash::Runner < Clamp::StrictCommand
:attribute_name => "log.format",
:default => LogStash::SETTINGS.get_default("log.format")

option ["--log.format.json_strict"], "FORMAT_JSON_STRICT",
I18n.t("logstash.runner.flag.log_format_json_strict"),
:attribute_name => "log.format.json_strict",
:default => LogStash::SETTINGS.get_default("log.format.json_strict")
option ["--log.format.json.fix_duplicate_message_fields"], "FORMAT_JSON_STRICT",
I18n.t("logstash.runner.flag.log_format_json_fix_duplicate_message_fields"),
:attribute_name => "log.format.json.fix_duplicate_message_fields",
:default => LogStash::SETTINGS.get_default("log.format.json.fix_duplicate_message_fields")

option ["--path.settings"], "SETTINGS_DIR",
I18n.t("logstash.runner.flag.path_settings"),
Expand Down
2 changes: 1 addition & 1 deletion logstash-core/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ en:
log_format: |+
Specify if Logstash should write its own logs in JSON form (one
event per line) or in plain text (using Ruby's Object#inspect)
log_format_json_strict: |+
log_format_json_fix_duplicate_message_fields: |+
Enable to avoid duplication of message fields in JSON form.
debug: |+
Set the log level to debug.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void writeStructuredMessage(StructuredMessage message, JsonGenerator gen
private static String renameParamNameIfClashingWithMessage(Map.Entry<Object, Object> entry) {
final String paramName = entry.getKey().toString();
if ("message".equals(paramName)) {
if ("true".equalsIgnoreCase(System.getProperty("ls.log.json.strict"))) {
if ("true".equalsIgnoreCase(System.getProperty("ls.log.format.json.fix_duplicate_message_fields"))) {
return "message_1";
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

public class CustomLogEventTests {
private static final String CONFIG = "log4j2-test1.xml";
public static final String STRICT_JSON_PROPERTY_NAME = "ls.log.json.strict";
public static final String STRICT_JSON_PROPERTY_NAME = "ls.log.format.json.fix_duplicate_message_fields";

@ClassRule
public static LoggerContextRule CTX = new LoggerContextRule(CONFIG);
Expand Down

0 comments on commit 9237560

Please sign in to comment.