-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MISC] Rework logger to enable pythonic custom logging configuration to be provided #4273
Conversation
vllm/logger.py
Outdated
_root_logger = logging.getLogger("vllm") | ||
default_log_level = os.getenv("LOG_LEVEL", _root_logger.level) | ||
logger.setLevel(default_log_level) | ||
for handler in _root_logger.handlers: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a change in behavior here! Previously it just gave all loggers the default handler. Now instead it copies them from the root vllm logger.
Again, unless someone is manually adding handlers to the root vllm logger, the new default behavior should match existing behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I have a question here. Do we even need handler + propgate False? If we don't set handler + propgate=True, doesn't it just use the handler from the root logger?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Responded over here: #4273 (comment)
logging_config: Dict = DEFAULT_LOGGING_CONFIG | ||
|
||
if VLLM_LOGGING_CONFIG_PATH: | ||
if not path.exists(VLLM_LOGGING_CONFIG_PATH): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the more exceptional route, but we could also silently fail and fallback to default logging config in some of these scenarios.
vllm/logger.py
Outdated
logger.propagate = False | ||
return logger | ||
|
||
if VLLM_CONFIGURE_LOGGING or VLLM_LOGGING_CONFIG_PATH: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's worth noting that this logic means that custom logging config can be provided and used even if VLLM_CONFIGURE_LOGGING
evaluates to false.
def init_logger(name: str): | ||
# Use the same settings as above for root logger | ||
logger = logging.getLogger(name) | ||
logger.setLevel(os.getenv("LOG_LEVEL", "DEBUG")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a change in behavior here! Previously, the requested logger's log level would always be configured. Now it is only configured if VLLM_CONFIGURE_LOGGING
evaluates to true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't relevant anymore because descendent loggers are no longer configured, and instead propagate their messages to the root logger that handles logging those messages (or not).
As such, the change in behavior is broader, but should still be fairly consistent since both approaches aimed to mimic the configuration of the root vLLM logger.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good! I mostly have questions, not blocking comments.
examples/logging_configuration.md
Outdated
flexibility from: | ||
|
||
- vLLM's default logging configuration (least flexible) | ||
- coarse grained custom logging configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a simple example or to a link to a relevant subsection here? for coarse grained & fined grained bullet points (the definition is not very straightforward)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried adding some examples of how to use the configs to achieve these states and I think there's now an example for each state. Let me know if that's sufficient. I can definitely add a link related to each option if you think it'd be beneficial. I'm optimistic that the overall scheme is simpler now and it may not be needed.
@@ -0,0 +1,234 @@ | |||
# Logging Configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love this doc!
vllm/logger.py
Outdated
_root_logger = logging.getLogger("vllm") | ||
default_log_level = os.getenv("LOG_LEVEL", _root_logger.level) | ||
logger.setLevel(default_log_level) | ||
for handler in _root_logger.handlers: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I have a question here. Do we even need handler + propgate False? If we don't set handler + propgate=True, doesn't it just use the handler from the root logger?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM given propagate=True + nit comments are addressed
@rkooo567, updates are complete, should you care to re-review at your leisure. |
@simon-mo I think it is good to go! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stamp
Rework logger to enable pythonic custom logging configuration to be provided
Moved from #4038 to here
This PR aims to update
vllm/logger.py
to extend vLLM to give users more ability to inject custom logging configuration in an idiomatic python way vialogging.config.dictConfig
.This PR changes existing behavior in a couple of minor ways, but in general aims to keep existing functionality intact such that there will be limited change in behavior if this code is merged. I've added comments to call out changes in behavior with explanations as to why I felt such a change was appropriate. A test was added before rework to ensure consistent behavior, so I'm fairly confidant existing behavior should be conserved.
Checkout
examples/logging_configuration.md
for some high level coverage of what these changes enable.I'm open to any thoughts or suggestions y'all might have to offer. Let me know 😁