title: Where / how / in what context is ipython's configuration file executed?
body: <p>Where is ipython's configuration file, which starts with <code>c = get_config()</code>, executed?  I'm asking because I want to understand what order things are done in ipython, e.g. why certain commands will not work if included as <code>c.InteractiveShellApp.exec_lines</code>.  </p>
  
  <p>This is related to my other question, <a href="https://stackoverflow.com/questions/11833654/log-ipython-output">Log IPython output?</a>, because I want access to a <code>logger</code> attribute, but I can't figure out how to access it in the configuration file, and by the time <code>exec_lines</code> are run, the logger has already started (it's too late).  </p>
  
  <p>EDIT: I've accepted a solution based on using a startup file in <code>ipython0.12+</code>.  Here is my implementation of that solution:</p>
  
  <pre><code>from time import strftime
  import os.path
  
  ip = get_ipython()
  
  #ldir = ip.profile_dir.log_dir 
  ldir = os.getcwd()
  fname = 'ipython_log_' + strftime('%Y-%m-%d') + ".py"
  filename = os.path.join(ldir, fname)
  notnew = os.path.exists(filename)
  
  
  try:
    ip.magic('logstart -o %s append' % filename)
    if notnew:
        ip.logger.log_write( u"########################################################\n" ) 
    else:
        ip.logger.log_write( u"#!/usr/bin/env python\n" )
        ip.logger.log_write( u"# " + fname + "\n" )
        ip.logger.log_write( u"# IPython automatic logging file\n" )
    ip.logger.log_write( u"# " + '# Started Logging At: '+ strftime('%Y-%m-%d %H:%M:%S\n') ) 
    ip.logger.log_write( u"########################################################\n" ) 
    print " Logging to "+filename
  except RuntimeError:
      print " Already logging to "+ip.logger.logfname
  </code></pre>
  
  <p>There are only two subtle differences from the proposed solution linked:
  1. saves log to <code>cwd</code> instead of some log directory (though I like that more...)
  2. <code>ip.magic_logstart</code> doesn't seem to exist, instead one should use <code>ip.magic('logstart')</code></p>