Coding⏱️ 3 min read📅 2026-06-03

How to Fix: logging.info doesn't show up on console but warn and error do

Logging info not appearing in console due to environment level change.

Quick Answer: Set the logging level to DEBUG or higher in your Python file or use a logging configuration file.

The issue of logging.info not showing up on console but warn and error does is a common problem that affects many Python developers. This occurs because the default logging level in Python is set to WARNING, which means that only log messages with a level greater than or equal to WARNING will be printed to the console.

This can be frustrating for developers who want to see all log messages, including INFO messages, in their terminal output.

💡 Why You Are Getting This Error

  • The root cause of this issue is the default logging configuration in Python. The logging module uses a hierarchical structure to categorize log messages, with levels ranging from DEBUG (the lowest) to CRITICAL (the highest). The default level for all handlers is set to WARNING.
  • This means that unless you explicitly set the logging level for a particular handler or logger to INFO or higher, INFO messages will not be printed to the console.

🛠️ Step-by-Step Verified Fixes

Changing the Default Logging Level

  1. Step 1: To fix this issue, you can change the default logging level to INFO by setting the logging.root.level attribute to 'INFO' in your Python code.
  2. Step 2: For example: `logging.basicConfig(level=logging.INFO)` or `logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s', level=logging.INFO)`.
  3. Step 3: Alternatively, you can also use the `log.setLevel()` method directly on a logger object, for example: `logger = logging.getLogger()`, `logger.setLevel(logging.INFO)`.

Configuring Logging Levels per Handler

  1. Step 1: Another way to fix this issue is to configure the logging level per handler. You can do this by creating a handler and setting its logging level to INFO or higher.
  2. Step 2: For example: `file_handler = logging.FileHandler('log_file.log')`, `file_handler.setLevel(logging.INFO)`
  3. Step 3: This approach allows you to set different logging levels for different handlers, which can be useful if you want to log messages at different levels for different purposes.

✨ Wrapping Up

In conclusion, the issue of logging.info not showing up on console but warn and error does is easily fixable by changing the default logging level or configuring logging levels per handler. By following one of the methods outlined above, you can ensure that all log messages are printed to the console as desired.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions