I was reviewing an answer about all logging, it was really helpful. Logging seems to always point back to here.
So it seems I can keep track of things by adding print statements. That’s a fine solution.
However, I built part of my app before discovering Streamlit and when I deploy, I still have code that uses logging
.
My question: Where do those logs go? Can I grab them? Are they secure? Thank you!
Welcome to the forum, @johncalculated! Where the logs go depends on how you have set up your logging
– you can set it to either write to a file, or write to the console, just like print. If you want those logs to show up in the streamlit log, you should be able to set the logger level
value in a .streamlit/config.toml
file Configuration - Streamlit Docs
2 Likes
Hey thank you very much! This was super helpful, I’ll dig into it.
@blackary thanks again. Just to be clear, the logs aren’t written anywhere, is that right? The only logging that’s done is to the console, not to a file.
Thank you! John
Correct. You could change your config to also/instead write them to a file, but if you’re hosting your app on Community Cloud, those log files would not necessarily exist long-term.
1 Like
You can also get a logging.Logger
in your code from: https://github.com/streamlit/streamlit/blob/1.28.1/lib/streamlit/logger.py#L103
import logging
import streamlit
# If you're curious of all the loggers
print(streamlit.logger._loggers)
streamlit_root_logger = logging.getLogger(streamlit.__name__)
@blackary Is there an integration available to ship these logs to a log destination like cloudwatch or ELK?
I haven’t done that in a long time, but I used to use GitHub - kislyuk/watchtower: Python CloudWatch Logging: Log Analytics and Application Intelligence to send logs to cloudwatch, and it worked well