1

I have a python package and the logging level is set as below (in app.py).

logger = logging.getLogger('app')
logger.handlers = []
logger.addHandler(logging.StreamHandler())
logger.setLevel(logging.ERROR)

logging.getLogger("requests").setLevel(logging.WARNING)

I generally import this module DbApp (from app.py) and directly run it. As this package is installed using pip, I don't want to change the logging level in the file.

How can I change from my main program to set the logging level?

from db.rest import DbApp    
app = DbApp()

1 Answer 1

1

I believe you can set the logging level dynamically using the setLevel API. As an example: logger.setLevel(logging.DEBUG)

For further info, you may refer to : https://docs.python.org/2/library/logging.html

Hope it helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.