mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
* logging: move init into environment's settings post-processor
Ensures that the non-runner command line utilities like `bin/logstash-keystore`
correctly initialize the logger as-configured.
* fixup: ensure we get ruby stdlib URI & File
(cherry picked from commit 2a5e54cd21
)
This commit is contained in:
parent
8d057881ae
commit
319e67dceb
2 changed files with 17 additions and 16 deletions
|
@ -112,6 +112,23 @@ module LogStash
|
|||
default_dlq_file_path = ::File.join(SETTINGS.get("path.data"), "dead_letter_queue")
|
||||
SETTINGS.register Setting::WritableDirectory.new("path.dead_letter_queue", default_dlq_file_path)
|
||||
|
||||
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.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"))
|
||||
java.lang.System.setProperty("ls.pipeline.separate_logs", settings.get("pipeline.separate_logs").to_s)
|
||||
unless java.lang.System.getProperty("log4j.configurationFile")
|
||||
log4j_config_location = ::File.join(settings.get("path.settings"), "log4j2.properties")
|
||||
|
||||
# Windows safe way to produce a file: URI.
|
||||
file_schema = "file://" + (LogStash::Environment.windows? ? "/" : "")
|
||||
LogStash::Logging::Logger::reconfigure(::URI.encode(file_schema + ::File.absolute_path(log4j_config_location)))
|
||||
end
|
||||
# override log level that may have been introduced from a custom log4j config file
|
||||
LogStash::Logging::Logger::configure_logging(settings.get("log.level"))
|
||||
end
|
||||
|
||||
SETTINGS.on_post_process do |settings|
|
||||
# If the data path is overridden but the queue path isn't recompute the queue path
|
||||
|
|
|
@ -299,22 +299,6 @@ class LogStash::Runner < Clamp::StrictCommand
|
|||
require "logstash/util/java_version"
|
||||
require "stud/task"
|
||||
|
||||
# Configure Logstash logging facility, this need to be done before everything else to
|
||||
# make sure the logger has the correct settings and the log level is correctly defined.
|
||||
java.lang.System.setProperty("ls.logs", setting("path.logs"))
|
||||
java.lang.System.setProperty("ls.log.format", setting("log.format"))
|
||||
java.lang.System.setProperty("ls.log.level", setting("log.level"))
|
||||
java.lang.System.setProperty("ls.pipeline.separate_logs", setting("pipeline.separate_logs").to_s)
|
||||
unless java.lang.System.getProperty("log4j.configurationFile")
|
||||
log4j_config_location = ::File.join(setting("path.settings"), "log4j2.properties")
|
||||
|
||||
# Windows safe way to produce a file: URI.
|
||||
file_schema = "file://" + (LogStash::Environment.windows? ? "/" : "")
|
||||
LogStash::Logging::Logger::reconfigure(URI.encode(file_schema + File.absolute_path(log4j_config_location)))
|
||||
end
|
||||
# override log level that may have been introduced from a custom log4j config file
|
||||
LogStash::Logging::Logger::configure_logging(setting("log.level"))
|
||||
|
||||
if log_configuration_contains_javascript_usage?
|
||||
logger.warn("Logging configuration uses appender or filter with scripting language JavaScript, which will be removed in a future major release of Logstash.")
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue