2

Currently if I run the following code from the python command line it writes to the file specified by filename as expected.

import logging
def test():
    logging.basicConfig(format='%(asctime)s %(message)s',
                        datefmt='%m/%d/%Y %I:%M:%S %p',
                        filename=r'C:\Users\theo\Documents\myLog.txt')
    logging.warning('Example logged message.')
test()

But when I copy the code into one of my functions and run the function with Pyscripter, it does not seem to write the file. How can I get logging to appear in Pyscripter?

13
  • You're going to need to show us some code, and generally give us more information. Is the function in the top-level script, or an imported module? Are you actually doing the import logging and logging.basicConfig(…) in the function? (Also all the dumb stuff, like: is the function actually being called?) Commented Jun 20, 2013 at 21:19
  • Consider pastebin.com/CWbDTb0c Commented Jun 20, 2013 at 21:23
  • the filename appears different in both snippets, is this actually the case? Commented Jun 20, 2013 at 21:31
  • the actual filepath is very long, the file paths shown are more representative. I guarantee the filepath does exist. Commented Jun 20, 2013 at 21:35
  • 1
    Is there actually a valid, writeable network share called \\Stuff\folder? If you just with open(r'\\Stuff\folder.test.log', 'w') as f: f.write('test') instead of using logging, does that work? Commented Jun 20, 2013 at 22:24

2 Answers 2

4

Pyscripter has an 'External Run' option ( Run > External Run (Alt + F9)), choosing this made the logging work.

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

1 Comment

Just want to add the "External Run" method is accessed by the menu option Run > External Run (Alt + F9), with the logging information directed to the Output tab rather than the Python Interpreter tab.
1

Switch the Python Engine to Internal. Go to run-->Pyhton Engine-->Internal

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.