Can I Redirect debug output from HTTPConnection to a file?

H

Harel

I'm using httplib.HTTPConnection to perform http connections and
during the beta period of the application I wanted to log its verbose
output [set_debuglevel(5)]. However, raising the debuglevel just
outputs it to stdout. can I redirect that to a file? My app uses the
logging module for logging and I'd like to use that to log into the
standard log it generates.

Any ideas?
Thanks,
Harel
 
H

Harel

I'll answer myself then:

import os
ioLogFile = file(LOG_FILE_PATH + IO_LOG_FILE, "w") #get a log file
created
os.dup2(config.ioLogFile.fileno(), 1) #route stdout (file descriptor
1) to the log file's one

Thanks
Harel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,146
Latest member
Vinay KumarNevatia_
Top