Logging from child page in multi page app

I am trying to do logging from multi page app.
I have run the Home .py like this
python -m streamlit run Home_v1.py --logger.level=warning 2>‘app_log.log’

In the above page the logging is happening fine.
Here is the code in the Home.py

logger = get_logger(__name__)

logger.info('Home info ' + str(dt.datetime.now()))

logger.warning('Home warning ' + str(dt.datetime.now()))

logger.debug('Home debug ' + str(dt.datetime.now()))

Then i have a childpage.py where i have used the logging same code for testing
but when i click on the child page and it comes up logging does not seem to be happening from the child page. Any suggestions or advise appreciated.

1 Like

Hi @Sai_SaiGraph! :wave:

I haven’t tried your solution, but I once created a little script that allows me to log in to any page of a multipage app.

Here it is below:

import streamlit as st

# Hardcoded password
correct_password = "one"

def check_password():
    """Returns `True` if the user has the correct password."""

    # Initialize 'password_correct' if it's not in the session state
    if "password_correct" not in st.session_state:
        st.session_state["password_correct"] = False

    # If the password has already been entered correctly, don't ask again
    if st.session_state.password_correct:
        return True

    # Initialize 'password' if it's not in the session state
    if "password" not in st.session_state:
        st.session_state["password"] = ""

    def password_entered():
        """Checks whether a password entered by the user is correct."""
        if st.session_state.password == correct_password:
            st.session_state.password_correct = True
            st.session_state.password_correct = False

    # Password not correct, show input + error.
        "Please authenticate to access the pages",
    if st.session_state.password_correct:
        return True
    elif st.session_state.password:
        st.error("😕 Password incorrect")
    return False

Feel free to try it and leave me feedback! :hugs:

Best wishes,


Thanks Charlie for your response. But i am talking about logger logging not authentication log in… i think your script refers to authentication login… please correct me… Thank you again…

This worked for me:

import logging

logging.basicConfig(filename=‘app.log’, filemode=‘w’, format=‘%(name)s - %(levelname)s - %(message)s’)

logging.warning(‘This will get logged to a file’)

logging.debug(‘This is a debug message’)

logging.info(‘This is an info message’)

logging.warning(‘This is a warning message’)

logging.error(‘This is an error message’)

logging.critical(‘This is a critical message’)

1 Like

Oops, my mistake!

I’m not familiar with Logger, and I thought the problem was about authentication logging, not server logging.

Anyway, glad you were able to find a solution to your issue! :blush:


This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.