Skip to content
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

Uvicorn logging settings #531

Merged
merged 5 commits into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions mlserver/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
def get_logger():
return logger

def apply_logging_file(settings: Settings):
logging.config.fileConfig(
settings.logging_settings, disable_existing_loggers=False
)


def configure_logger(settings: Settings = None):
logger = get_logger()
Expand All @@ -30,4 +35,7 @@ def configure_logger(settings: Settings = None):
if settings and settings.debug:
logger.setLevel(logging.DEBUG)

if settings and settings.logging_settings:
apply_logging_file(settings)

return logger
2 changes: 1 addition & 1 deletion mlserver/rest/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async def delete_custom_handlers(self, model: MLModel):

async def start(self):
cfg = uvicorn.Config(
self._app, host=self._settings.host, port=self._settings.http_port
self._app, host=self._settings.host, port=self._settings.http_port, log_config=self._settings.logging_settings
)
self._server = _NoSignalServer(cfg)
await self._server.serve()
Expand Down
4 changes: 4 additions & 0 deletions mlserver/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ class Config:
`None` to disable it
"""

# Logging settings
logging_settings: Optional[str] = None
"""Path to logging config file"""


class ModelParameters(BaseSettings):
"""
Expand Down