question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

logging library doesn't seem to work with spyder

See original GitHub issue

Hello,

I’m trying to run a script using python standard library ‘logging’. This script works fine from the command line but when run from Spyder, no log is printed.

My configuration is: Windows 7 Python 2.7.10 :: Anaconda 2.3.0 (64-bit) spyder-app 2.3.5.2

The script is:

# -*- coding: utf-8 -*-
"""
Simple test using logging
"""
import logging

# Logger configuration:
log_level = logging.DEBUG 
log_format = '%(levelname)s:%(message)s'

# Testing logger
logger = logging.root
logger.basicConfig = logging.basicConfig(format=log_format, filename='test.log', level=log_level)
logger.info('Testing logger (info)')
logger.debug('Testing logger (debug)')
logger.warning('Testing logger (warn)')
logger.info("")

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:34 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
jgriffin2commented, Jun 30, 2020

Thanks! force=True worked on my system Mac, Python 3.8.1, Spyder 4.1.3)

1reaction
ccordoba12commented, Jun 23, 2020

@gokhalen, your use case also seems fixed in Python 3.8, by passing a new parameter called force=True to basicConfig so it can be reset each time you run new code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

logging library doesn't seem to work well with spyder #14651
I'm trying to run a script using python standard library 'logging' module. This script works fine from Python IDE but when run from...
Read more >
Unexplained behaviour of python logging in spyder that differs ...
I am really struggling with Python's logging library, which seems so promising. This is perhaps in part because I typically use Spyder IDE....
Read more >
logging — Logging facility for Python — Python 3.11.1 ...
The key benefit of having the logging API provided by a standard library module is ... so that the next formatter to handle...
Read more >
Common Illnesses — Spyder 5 documentation
If you receive the message An error occurred while starting the kernel in the IPython Console, Spyder was unable to launch a new...
Read more >
Python Tutorial: Logging Basics - Logging to Files ... - YouTube
In this Python Tutorial, we will be going over the basics of logging. We will learn how to switch out our print statements...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found