-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Apply logger config to all logger instances #7858
Comments
@kaisa-kucherenko Thanks for reporting this issue! I was able to reproduce this, but I think the logger settings are mostly for the Streamlit internal logging. And this is working as expected. If you like to apply the same settings to your logger instance, you can initialize it like this: import logging
import streamlit as st
from streamlit.logger import get_logger
log = get_logger("my_tool_logger")
st.write("Some text of page") But this is more like an internal API, so it might be changed in future versions. I'm also adding @kajarenc to this thread since he made some changes to the logger recently. |
@lukasmasuch Thank you for the suggestion, but I find it a bit unclear. The documentation for config.toml and the logger section doesn't provide any clues about this issue. It seems like a bug. I came across this discussion: link to the GitHub issue. |
Yep, I agree that we should clarify this a bit more in our docs. Maybe it's also an unexpected behavior, @kajarenc might be able to say more on this. |
Hey @kaisa-kucherenko, thank you for opening this issue! You are right, the one implication that we have changed our root logger to a "streamlit" logger, is that just getting the logger via So my comment here is partially wrong. The idea of that PR was to give streamlit app developers more freedom to configure their app logs, and not bound them with streamlit internal logger. In order to keep the old behavior, you can either import import logging
import streamlit as st
from streamlit.logger import get_logger
log = get_logger("my_tool_logger")
st.write("Some text of page") or use "streamlit" logger explicitly import streamlit as st
import logging
log = logging.getLogger("streamlit")
st.write("Some text of page")
log.info("Page loaded") this should also work. I agree that it is not clear from the documentation, so we should change docs to highlight the fact that logger configuration applies to streamlit logger. |
@kajarenc or @sfc-gh-dmatthews, can one of you update the docstring to make this more clear and close this issue? |
Any updates on this ? |
@jrieke I have a PR to update the description, but this issue is currently labeled as an enhancement request to change the behavior. Do you want this closed with the clarification "this setting is for Streamlit's internal logger" and "won't do" for the enhancement request? Or, do you want to keep this open as an enhancement request? |
Yeah I think we can close this issue once the docs changes are merged. I don't think we'll revert that back to the old setting again. |
Checklist
Summary
Starting from version 1.22.0 of Streamlit and above, the options in the config.toml file under the [logger] section no longer function. I am currently in the process of upgrading from Streamlit version 1.10.0 to the latest 1.29.0 and have observed that logs cease to display while the application is running.
The logging level is set to 'Info' in the file, but logs are only appearing from the 'Warning' level and above. Additionally, the formatting doesn't match the configuration file.
config.toml
[logger]
level = "info"
messageFormat = "%(asctime)s - %(levelname)s %(filename)s:%(lineno)-4d - %(message)s"
Reproducible Code Example
Steps To Reproduce
Expected Behavior
Logs are displayed in the standard output.
https://img.serpstat.com/kaisa/2023-12-19_ZFDITjqD.png
Current Behavior
When the logging level is set to 'info,' logs do not appear in the standard output. The message format does not conform to the configuration specified in the 'config.toml' file.
Is this a regression?
Debug info
Additional Information
I tested this on every version from 1.29.0 to 1.21.0, and it appears that it broke starting from version 1.22.0. It worked fine in version 1.21.0.
The text was updated successfully, but these errors were encountered: