Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8335545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:42:32+00:00 2026-06-09T03:42:32+00:00

Is there any way to make IPython’s logging capability include output as well as

  • 0

Is there any way to make IPython’s logging capability include output as well as input?

This is what a log file looks like currently:

#!/usr/bin/env python 
# 2012-08-06.py 
# IPython automatic logging file
# 12:02 
# =================================
print "test"

I’d like to have one more line show up:

#!/usr/bin/env python 
# 2012-08-06.py 
# IPython automatic logging file
# 12:02 
# =================================
print "test"
# test

(the # is because I assume that is needed to prevent breaking IPython’s logplay feature)

I suppose this is possible using IPython notebooks, but on at least one machine I need this for, I’m limited to ipython 0.10.2.

EDIT: I’d like to know how to set this up automatically, i.e. within the configuration file. Right now my config looks like

from time import strftime
import os
logfilename = strftime('ipython_log_%Y-%m-%d')+".py" 
logfilepath = "%s/%s" % (os.getcwd(),logfilename) 

file_handle = open(logfilepath,'a') 
file_handle.write('########################################################\n') 
out_str = '# Started Logging At: '+ strftime('%Y-%m-%d %H:%M:%S\n') 
file_handle.write(out_str) 
file_handle.write('########################################################\n') 
file_handle.close() 

c.TerminalInteractiveShell.logappend = logfilepath
c.TerminalInteractiveShell.logstart = True

but specifying c.TerminalInteractiveShell.log_output = True seems to have no affect

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T03:42:33+00:00Added an answer on June 9, 2026 at 3:42 am

    There’s the -o option for %logstart:

    -o: log also IPython's output.  In this mode, all commands which
      generate an Out[NN] prompt are recorded to the logfile, right after
      their corresponding input line.  The output lines are always
      prepended with a '#[Out]# ' marker, so that the log remains valid
      Python code.
    

    ADDENDUM: If you are in an interactive ipython session for which logging has already been started, you must first stop logging and then restart:

    In [1]: %logstop
    
    In [2]: %logstart -o
    Activating auto-logging. Current session state plus future input saved.
    Filename       : ./ipython.py
    Mode           : backup
    Output logging : True
    Raw input log  : False
    Timestamping   : False
    State          : active
    

    Observe that, after the restart, “Output Logging” is now “True”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to make this code shorter? price1 = input(\nEnter price here:
Is there any way to make this work in Java? public static void change(List<?
Is there any way to make code more compact for this situation? // pseudocode
Is there any way to make this solution IE6 and IE7 compatible? http://jsfiddle.net/kirkstrobeck/sDh7s/1/ Pulled
Is there any way to make py2exe output .py source files instead of byte-compiled
Is there any way to make possible to use functions in your file before
Is there any way to make a telnet app to clear the output client-side
Is there any way to make pointers read a file as a block of
Is there any way to make radius border without -moz , cause this only
Is there any way to make a single View (in this case a TextView)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.