| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> |
| 5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> |
| 6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> |
| 7 | <link rel="first" href="lib.html" title='Python Library Reference' /> |
| 8 | <link rel='contents' href='contents.html' title="Contents" /> |
| 9 | <link rel='index' href='genindex.html' title='Index' /> |
| 10 | <link rel='last' href='about.html' title='About this document...' /> |
| 11 | <link rel='help' href='about.html' title='About this document...' /> |
| 12 | <link rel="next" href="logging-config-fileformat.html" /> |
| 13 | <link rel="prev" href="node361.html" /> |
| 14 | <link rel="parent" href="node361.html" /> |
| 15 | <link rel="next" href="logging-config-fileformat.html" /> |
| 16 | <meta name='aesop' content='information' /> |
| 17 | <title>6.29.10.1 Configuration functions</title> |
| 18 | </head> |
| 19 | <body> |
| 20 | <DIV CLASS="navigation"> |
| 21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> |
| 22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 23 | <tr> |
| 24 | <td class='online-navigation'><a rel="prev" title="6.29.10 Configuration" |
| 25 | href="node361.html"><img src='../icons/previous.png' |
| 26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 27 | <td class='online-navigation'><a rel="parent" title="6.29.10 Configuration" |
| 28 | href="node361.html"><img src='../icons/up.png' |
| 29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 30 | <td class='online-navigation'><a rel="next" title="6.29.10.2 Configuration file format" |
| 31 | href="logging-config-fileformat.html"><img src='../icons/next.png' |
| 32 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 33 | <td align="center" width="100%">Python Library Reference</td> |
| 34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 35 | href="contents.html"><img src='../icons/contents.png' |
| 36 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 38 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 39 | <td class='online-navigation'><a rel="index" title="Index" |
| 40 | href="genindex.html"><img src='../icons/index.png' |
| 41 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 42 | </tr></table> |
| 43 | <div class='online-navigation'> |
| 44 | <b class="navlabel">Previous:</b> |
| 45 | <a class="sectref" rel="prev" href="node361.html">6.29.10 Configuration</A> |
| 46 | <b class="navlabel">Up:</b> |
| 47 | <a class="sectref" rel="parent" href="node361.html">6.29.10 Configuration</A> |
| 48 | <b class="navlabel">Next:</b> |
| 49 | <a class="sectref" rel="next" href="logging-config-fileformat.html">6.29.10.2 Configuration file format</A> |
| 50 | </div> |
| 51 | <hr /></div> |
| 52 | </DIV> |
| 53 | <!--End of Navigation Panel--> |
| 54 | |
| 55 | <H3><A NAME="SECTION00829101000000000000000"></A><A NAME="logging-config-api"></A> |
| 56 | <BR> |
| 57 | 6.29.10.1 Configuration functions |
| 58 | </H3> |
| 59 | |
| 60 | <P> |
| 61 | The following functions allow the logging module to be |
| 62 | configured. Before they can be used, you must import |
| 63 | <tt class="module">logging.config</tt>. Their use is optional -- you can configure |
| 64 | the logging module entirely by making calls to the main API (defined |
| 65 | in <tt class="module">logging</tt> itself) and defining handlers which are declared |
| 66 | either in <tt class="module">logging</tt> or <tt class="module">logging.handlers</tt>. |
| 67 | |
| 68 | <P> |
| 69 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 70 | <td><nobr><b><tt id='l2h-2563' xml:id='l2h-2563' class="function">fileConfig</tt></b>(</nobr></td> |
| 71 | <td><var>fname</var><big>[</big><var>, defaults</var><big>]</big><var></var>)</td></tr></table></dt> |
| 72 | <dd> |
| 73 | Reads the logging configuration from a ConfigParser-format file named |
| 74 | <var>fname</var>. This function can be called several times from an application, |
| 75 | allowing an end user the ability to select from various pre-canned |
| 76 | configurations (if the developer provides a mechanism to present the |
| 77 | choices and load the chosen configuration). Defaults to be passed to |
| 78 | ConfigParser can be specified in the <var>defaults</var> argument. |
| 79 | </dl> |
| 80 | |
| 81 | <P> |
| 82 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 83 | <td><nobr><b><tt id='l2h-2564' xml:id='l2h-2564' class="function">listen</tt></b>(</nobr></td> |
| 84 | <td><var></var><big>[</big><var>port</var><big>]</big><var></var>)</td></tr></table></dt> |
| 85 | <dd> |
| 86 | Starts up a socket server on the specified port, and listens for new |
| 87 | configurations. If no port is specified, the module's default |
| 88 | <tt class="constant">DEFAULT_LOGGING_CONFIG_PORT</tt> is used. Logging configurations |
| 89 | will be sent as a file suitable for processing by <tt class="function">fileConfig()</tt>. |
| 90 | Returns a <tt class="class">Thread</tt> instance on which you can call <tt class="method">start()</tt> |
| 91 | to start the server, and which you can <tt class="method">join()</tt> when appropriate. |
| 92 | To stop the server, call <tt class="function">stopListening()</tt>. To send a configuration |
| 93 | to the socket, read in the configuration file and send it to the socket |
| 94 | as a string of bytes preceded by a four-byte length packed in binary using |
| 95 | struct.<code>pack(">L", n)</code>. |
| 96 | </dl> |
| 97 | |
| 98 | <P> |
| 99 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 100 | <td><nobr><b><tt id='l2h-2565' xml:id='l2h-2565' class="function">stopListening</tt></b>(</nobr></td> |
| 101 | <td><var></var>)</td></tr></table></dt> |
| 102 | <dd> |
| 103 | Stops the listening server which was created with a call to |
| 104 | <tt class="function">listen()</tt>. This is typically called before calling <tt class="method">join()</tt> |
| 105 | on the return value from <tt class="function">listen()</tt>. |
| 106 | </dl> |
| 107 | |
| 108 | <P> |
| 109 | |
| 110 | <DIV CLASS="navigation"> |
| 111 | <div class='online-navigation'> |
| 112 | <p></p><hr /> |
| 113 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 114 | <tr> |
| 115 | <td class='online-navigation'><a rel="prev" title="6.29.10 Configuration" |
| 116 | href="node361.html"><img src='../icons/previous.png' |
| 117 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 118 | <td class='online-navigation'><a rel="parent" title="6.29.10 Configuration" |
| 119 | href="node361.html"><img src='../icons/up.png' |
| 120 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 121 | <td class='online-navigation'><a rel="next" title="6.29.10.2 Configuration file format" |
| 122 | href="logging-config-fileformat.html"><img src='../icons/next.png' |
| 123 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 124 | <td align="center" width="100%">Python Library Reference</td> |
| 125 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 126 | href="contents.html"><img src='../icons/contents.png' |
| 127 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 128 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 129 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 130 | <td class='online-navigation'><a rel="index" title="Index" |
| 131 | href="genindex.html"><img src='../icons/index.png' |
| 132 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 133 | </tr></table> |
| 134 | <div class='online-navigation'> |
| 135 | <b class="navlabel">Previous:</b> |
| 136 | <a class="sectref" rel="prev" href="node361.html">6.29.10 Configuration</A> |
| 137 | <b class="navlabel">Up:</b> |
| 138 | <a class="sectref" rel="parent" href="node361.html">6.29.10 Configuration</A> |
| 139 | <b class="navlabel">Next:</b> |
| 140 | <a class="sectref" rel="next" href="logging-config-fileformat.html">6.29.10.2 Configuration file format</A> |
| 141 | </div> |
| 142 | </div> |
| 143 | <hr /> |
| 144 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> |
| 145 | </DIV> |
| 146 | <!--End of Navigation Panel--> |
| 147 | <ADDRESS> |
| 148 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. |
| 149 | </ADDRESS> |
| 150 | </BODY> |
| 151 | </HTML> |