-
-
Notifications
You must be signed in to change notification settings - Fork 408
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
docs: Added information about the JSON-like logging format for the standard library #3990
Conversation
Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/3990 |
A friendly ping @provinzkraut. Could you help me get a review for this PR? |
Not sure if this belongs in the Litestar logging tutorial, as it strictly deals with stdlib logging configuration. Maybe it would be better to link to the stdlib logging docs? |
There are no such examples in the stdlib logging documentation. They are also not listed in the stdlib cookbook. Maybe I can create a for from litestar import Litestar, Request, get
from litestar.logging import LoggingConfig, JsonFormat
@get("/")
def my_router_handler(request: Request) -> None:
request.logger.info("inside a request")
return None
logging_config = LoggingConfig(
root={"level": "INFO", "handlers": ["queue_listener"]},
formatters={
"standard": {"format": JsonFormat(["%(asctime)s", "%(name)s", "%(levelname)s", "%(message)s"])} # {'asctime': '%(asctime)s', 'name': ' %(name)s', 'levelname': ' %(levelname)s', 'message': ' %(message)s'}
},
log_exceptions="always",
)
app = Litestar(route_handlers=[my_router_handler], logging_config=logging_config) I think this is a useful feature. |
Sounds to me like you should make a PR to the stdlib docs then :) |
Thanks for feedback. It's was very usefull |
Description
Using Python standard library
sectionLogginConfig
Closes
#3827