[improve][fn]: Added logLevel to change the log level of Function/Source/Sink Pod/Process to desired Level #363
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Master Issue: apache#23783
Motivation:
The
pulsar.log.level
property inkubernetes_instance_log4j2.xml
&java_instance_log4j2.xml
files in the Pulsar Functions runtime is responsible for configuring the log settings for function pods when using the Java runtime in Kubernetes StatefulSets & for process runtime respectively. Currently, this configuration file is hardcoded to use theINFO
log level, which restricts flexibility when more granular logging (such asDEBUG
level) is needed for troubleshooting or deeper monitoring. This limitation is particularly impactful when debugging issues related to sources, sinks, or function executions, where more detailed logs could be beneficial.Presently, adjusting the log level requires manual changes to the
kubernetes_instance_log4j2.xml
orjava_instance_log4j2.xml
file, which is inefficient and error-prone, especially in dynamic environments. There is no built-in way to modify the log level dynamically without altering the configuration file directly.This PR introduces a new argument (
logLevel
) to override the JVM property-Dpulsar.log.level=info
at runtime for functions, sources, and sinks. This change provides a more flexible and dynamic approach to adjust log verbosity based on specific needs, such as enablingDEBUG
orERROR
logs for better diagnostics during troubleshooting.Modifications:
Introduction of
logLevel
Argument: Added a newlogLevel
argument for Pulsar Functions, Sources, and Sinks, which allows the user to override the default JVM property-Dpulsar.log.level=info
. This enables setting custom log levels (e.g.,DEBUG
,ERROR
) dynamically at runtime without modifying thekubernetes_instance_log4j2.xml
orjava_instance_log4j2.xml
file.JVM Property Override: The new
logLevel
argument directly overrides the-Dpulsar.log.level
property, giving users control over the logging level without needing to edit the underlying configuration file.Backward Compatibility: The default log level remains
INFO
unless the newlogLevel
argument is provided. This ensures that existing deployments continue to function as before.This update enhances the troubleshooting and monitoring capabilities of Pulsar Functions, offering greater flexibility while preserving the simplicity and stability of existing configurations.
Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
Does this pull request potentially affect one of the following parts:
If
yes
was chosen, please highlight the changeslogLevel
for creating/updating function/source/sinkDocumentation
Check the box below or label this PR directly (if you have committer privilege).
Need to update docs?
doc-required
(If you need help on updating docs, create a doc issue)
no-need-doc
(Please explain why)
doc
(If this PR contains doc changes)