Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / src / nas,5.n2.os.2 / lib / python / html / python / lib / logging-config-fileformat.html
CommitLineData
86530b38
AT
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="prev" href="logging-config-api.html" />
13<link rel="parent" href="node361.html" />
14<link rel="next" href="module-platform.html" />
15<meta name='aesop' content='information' />
16<title>6.29.10.2 Configuration file format</title>
17</head>
18<body>
19<DIV CLASS="navigation">
20<div id='top-navigation-panel' xml:id='top-navigation-panel'>
21<table align="center" width="100%" cellpadding="0" cellspacing="2">
22<tr>
23<td class='online-navigation'><a rel="prev" title="6.29.10.1 Configuration functions"
24 href="logging-config-api.html"><img src='../icons/previous.png'
25 border='0' height='32' alt='Previous Page' width='32' /></A></td>
26<td class='online-navigation'><a rel="parent" title="6.29.10 Configuration"
27 href="node361.html"><img src='../icons/up.png'
28 border='0' height='32' alt='Up One Level' width='32' /></A></td>
29<td class='online-navigation'><a rel="next" title="6.30 platform "
30 href="module-platform.html"><img src='../icons/next.png'
31 border='0' height='32' alt='Next Page' width='32' /></A></td>
32<td align="center" width="100%">Python Library Reference</td>
33<td class='online-navigation'><a rel="contents" title="Table of Contents"
34 href="contents.html"><img src='../icons/contents.png'
35 border='0' height='32' alt='Contents' width='32' /></A></td>
36<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
37 border='0' height='32' alt='Module Index' width='32' /></a></td>
38<td class='online-navigation'><a rel="index" title="Index"
39 href="genindex.html"><img src='../icons/index.png'
40 border='0' height='32' alt='Index' width='32' /></A></td>
41</tr></table>
42<div class='online-navigation'>
43<b class="navlabel">Previous:</b>
44<a class="sectref" rel="prev" href="logging-config-api.html">6.29.10.1 Configuration functions</A>
45<b class="navlabel">Up:</b>
46<a class="sectref" rel="parent" href="node361.html">6.29.10 Configuration</A>
47<b class="navlabel">Next:</b>
48<a class="sectref" rel="next" href="module-platform.html">6.30 platform </A>
49</div>
50<hr /></div>
51</DIV>
52<!--End of Navigation Panel-->
53
54<H3><A NAME="SECTION00829102000000000000000"></A><A NAME="logging-config-fileformat"></A>
55<BR>
566.29.10.2 Configuration file format
57</H3>
58
59<P>
60The configuration file format understood by <tt class="function">fileConfig()</tt> is
61based on ConfigParser functionality. The file must contain sections
62called <code>[loggers]</code>, <code>[handlers]</code> and <code>[formatters]</code>
63which identify by name the entities of each type which are defined in
64the file. For each such entity, there is a separate section which
65identified how that entity is configured. Thus, for a logger named
66<code>log01</code> in the <code>[loggers]</code> section, the relevant
67configuration details are held in a section
68<code>[logger_log01]</code>. Similarly, a handler called <code>hand01</code> in
69the <code>[handlers]</code> section will have its configuration held in a
70section called <code>[handler_hand01]</code>, while a formatter called
71<code>form01</code> in the <code>[formatters]</code> section will have its
72configuration specified in a section called
73<code>[formatter_form01]</code>. The root logger configuration must be
74specified in a section called <code>[logger_root]</code>.
75
76<P>
77Examples of these sections in the file are given below.
78
79<P>
80<div class="verbatim"><pre>
81[loggers]
82keys=root,log02,log03,log04,log05,log06,log07
83
84[handlers]
85keys=hand01,hand02,hand03,hand04,hand05,hand06,hand07,hand08,hand09
86
87[formatters]
88keys=form01,form02,form03,form04,form05,form06,form07,form08,form09
89</pre></div>
90
91<P>
92The root logger must specify a level and a list of handlers. An
93example of a root logger section is given below.
94
95<P>
96<div class="verbatim"><pre>
97[logger_root]
98level=NOTSET
99handlers=hand01
100</pre></div>
101
102<P>
103The <code>level</code> entry can be one of <code>DEBUG, INFO, WARNING,
104ERROR, CRITICAL</code> or <code>NOTSET</code>. For the root logger only,
105<code>NOTSET</code> means that all messages will be logged. Level values are
106<tt class="function">eval()</tt>uated in the context of the <code>logging</code> package's
107namespace.
108
109<P>
110The <code>handlers</code> entry is a comma-separated list of handler names,
111which must appear in the <code>[handlers]</code> section. These names must
112appear in the <code>[handlers]</code> section and have corresponding
113sections in the configuration file.
114
115<P>
116For loggers other than the root logger, some additional information is
117required. This is illustrated by the following example.
118
119<P>
120<div class="verbatim"><pre>
121[logger_parser]
122level=DEBUG
123handlers=hand01
124propagate=1
125qualname=compiler.parser
126</pre></div>
127
128<P>
129The <code>level</code> and <code>handlers</code> entries are interpreted as for
130the root logger, except that if a non-root logger's level is specified
131as <code>NOTSET</code>, the system consults loggers higher up the hierarchy
132to determine the effective level of the logger. The <code>propagate</code>
133entry is set to 1 to indicate that messages must propagate to handlers
134higher up the logger hierarchy from this logger, or 0 to indicate that
135messages are <strong>not</strong> propagated to handlers up the hierarchy. The
136<code>qualname</code> entry is the hierarchical channel name of the logger,
137that is to say the name used by the application to get the logger.
138
139<P>
140Sections which specify handler configuration are exemplified by the
141following.
142
143<P>
144<div class="verbatim"><pre>
145[handler_hand01]
146class=StreamHandler
147level=NOTSET
148formatter=form01
149args=(sys.stdout,)
150</pre></div>
151
152<P>
153The <code>class</code> entry indicates the handler's class (as determined by
154<tt class="function">eval()</tt> in the <code>logging</code> package's namespace). The
155<code>level</code> is interpreted as for loggers, and <code>NOTSET</code> is taken
156to mean "log everything".
157
158<P>
159The <code>formatter</code> entry indicates the key name of the formatter for
160this handler. If blank, a default formatter
161(<code>logging._defaultFormatter</code>) is used. If a name is specified, it
162must appear in the <code>[formatters]</code> section and have a
163corresponding section in the configuration file.
164
165<P>
166The <code>args</code> entry, when <tt class="function">eval()</tt>uated in the context of
167the <code>logging</code> package's namespace, is the list of arguments to
168the constructor for the handler class. Refer to the constructors for
169the relevant handlers, or to the examples below, to see how typical
170entries are constructed.
171
172<P>
173<div class="verbatim"><pre>
174[handler_hand02]
175class=FileHandler
176level=DEBUG
177formatter=form02
178args=('python.log', 'w')
179
180[handler_hand03]
181class=handlers.SocketHandler
182level=INFO
183formatter=form03
184args=('localhost', handlers.DEFAULT_TCP_LOGGING_PORT)
185
186[handler_hand04]
187class=handlers.DatagramHandler
188level=WARN
189formatter=form04
190args=('localhost', handlers.DEFAULT_UDP_LOGGING_PORT)
191
192[handler_hand05]
193class=handlers.SysLogHandler
194level=ERROR
195formatter=form05
196args=(('localhost', handlers.SYSLOG_UDP_PORT), handlers.SysLogHandler.LOG_USER)
197
198[handler_hand06]
199class=handlers.NTEventLogHandler
200level=CRITICAL
201formatter=form06
202args=('Python Application', '', 'Application')
203
204[handler_hand07]
205class=handlers.SMTPHandler
206level=WARN
207formatter=form07
208args=('localhost', 'from@abc', ['user1@abc', 'user2@xyz'], 'Logger Subject')
209
210[handler_hand08]
211class=handlers.MemoryHandler
212level=NOTSET
213formatter=form08
214target=
215args=(10, ERROR)
216
217[handler_hand09]
218class=handlers.HTTPHandler
219level=NOTSET
220formatter=form09
221args=('localhost:9022', '/log', 'GET')
222</pre></div>
223
224<P>
225Sections which specify formatter configuration are typified by the following.
226
227<P>
228<div class="verbatim"><pre>
229[formatter_form01]
230format=F1 %(asctime)s %(levelname)s %(message)s
231datefmt=
232</pre></div>
233
234<P>
235The <code>format</code> entry is the overall format string, and the
236<code>datefmt</code> entry is the <tt class="function">strftime()</tt>-compatible date/time format
237string. If empty, the package substitutes ISO8601 format date/times, which
238is almost equivalent to specifying the date format string "The ISO8601 format also specifies milliseconds, which are appended to the
239result of using the above format string, with a comma separator. An example
240time in ISO8601 format is <code>2003-01-23 00:29:50,411</code>.
241
242<DIV CLASS="navigation">
243<div class='online-navigation'>
244<p></p><hr />
245<table align="center" width="100%" cellpadding="0" cellspacing="2">
246<tr>
247<td class='online-navigation'><a rel="prev" title="6.29.10.1 Configuration functions"
248 href="logging-config-api.html"><img src='../icons/previous.png'
249 border='0' height='32' alt='Previous Page' width='32' /></A></td>
250<td class='online-navigation'><a rel="parent" title="6.29.10 Configuration"
251 href="node361.html"><img src='../icons/up.png'
252 border='0' height='32' alt='Up One Level' width='32' /></A></td>
253<td class='online-navigation'><a rel="next" title="6.30 platform "
254 href="module-platform.html"><img src='../icons/next.png'
255 border='0' height='32' alt='Next Page' width='32' /></A></td>
256<td align="center" width="100%">Python Library Reference</td>
257<td class='online-navigation'><a rel="contents" title="Table of Contents"
258 href="contents.html"><img src='../icons/contents.png'
259 border='0' height='32' alt='Contents' width='32' /></A></td>
260<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
261 border='0' height='32' alt='Module Index' width='32' /></a></td>
262<td class='online-navigation'><a rel="index" title="Index"
263 href="genindex.html"><img src='../icons/index.png'
264 border='0' height='32' alt='Index' width='32' /></A></td>
265</tr></table>
266<div class='online-navigation'>
267<b class="navlabel">Previous:</b>
268<a class="sectref" rel="prev" href="logging-config-api.html">6.29.10.1 Configuration functions</A>
269<b class="navlabel">Up:</b>
270<a class="sectref" rel="parent" href="node361.html">6.29.10 Configuration</A>
271<b class="navlabel">Next:</b>
272<a class="sectref" rel="next" href="module-platform.html">6.30 platform </A>
273</div>
274</div>
275<hr />
276<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
277</DIV>
278<!--End of Navigation Panel-->
279<ADDRESS>
280See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
281</ADDRESS>
282</BODY>
283</HTML>