Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Logging

1 view
Skip to first unread message

Kamus of Kadizhar

unread,
Dec 18, 2003, 7:16:44 AM12/18/03
to
Does anyone have a working example or a recipe of a simple logging
system using the logging module? Any FM I can refer to?

I can't seem to get it right - I can't even make sense of the standard
library docs. What do I have to do to log records to a file?

(Newbie Q, as you might guess...)

-Kamus

--
o__ | If you're old, eat right and ride a decent bike.
,>/'_ | Q.
(_)\(_) | Usenet posting`

John Abel

unread,
Dec 18, 2003, 7:32:46 AM12/18/03
to Kamus of Kadizhar, pytho...@python.org
Try this. It records anything Warning and above.

logFacility = logging.getLogger( "MyApp" )
logFile = logging.FileHandler( "LogFile.log" )
logFormat = logging.Formatter( '%(asctime)s %(levelname)s
%(message)s' )
logFile.setFormatter( logFormat )
logFacility.addHandler( logFile )
logFacility.setLevel( logging.WARNING )

logFacility.info( "Starting Up" )
**

HTH

John

Anthony Baxter

unread,
Dec 18, 2003, 7:40:33 AM12/18/03
to Kamus of Kadizhar, pytho...@python.org

>>> Kamus of Kadizhar wrote

> Does anyone have a working example or a recipe of a simple logging
> system using the logging module? Any FM I can refer to?
>
> I can't seem to get it right - I can't even make sense of the standard
> library docs. What do I have to do to log records to a file?

Did you look in the logging documentation? At the end of the
current docs, there's a simple example:

http://www.python.org/dev/doc/devel/lib/node302.html

--
Anthony Baxter <ant...@interlink.com.au>
It's never too late to have a happy childhood.


Kamus of Kadizhar

unread,
Dec 18, 2003, 8:19:44 AM12/18/03
to
On Thu, 18 Dec 2003 23:40:33 +1100, Anthony Baxter wrote:

> Did you look in the logging documentation? At the end of the
> current docs, there's a simple example:

Missed that.

Is there a search on python.org that only searches docs? That would be
really helpful.... I keep coming up with gobs of irrelevant stuff on my
searches.

I keep missing simple stuff like that.

-Kamus

Gerrit Holl

unread,
Dec 18, 2003, 8:50:48 AM12/18/03
to Kamus of Kadizhar, pytho...@python.org
Kamus of Kadizhar wrote:
> > Did you look in the logging documentation? At the end of the
> > current docs, there's a simple example:
>
> Missed that.

> Is there a search on python.org that only searches docs? That would be
> really helpful.... I keep coming up with gobs of irrelevant stuff on my
> searches.
>
> I keep missing simple stuff like that.

Not really a search engine, but the index of the documentation can be
very useful. Also very useful is simply browsing the documentation
without looking for something specific, just to get the feeling what it
is there is.

Gerrit.

--
49. If any one take money from a merchant, and give the merchant a
field tillable for corn or sesame and order him to plant corn or sesame in
the field, and to harvest the crop; if the cultivator plant corn or sesame
in the field, at the harvest the corn or sesame that is in the field shall
belong to the owner of the field and he shall pay corn as rent, for the
money he received from the merchant, and the livelihood of the cultivator
shall he give to the merchant.
-- 1780 BC, Hammurabi, Code of Law
--
Asperger's Syndrome - a personal approach:
http://people.nl.linux.org/~gerrit/english/

Pieter Claerhout

unread,
Dec 18, 2003, 8:47:44 AM12/18/03
to pytho...@python.org
One I forgot to mention... If you are looking for the docs for a specific
module, you can use the following URL:

http://python.org/doc/2.3/modindex.html

cheers,


pieter

Creo
pieter claerhout | product support prinergy | tel: +32 2 352 2511 |
pieter.c...@creo.com | www.creo.com

IMAGINE CREATE BELIEVE(tm)


-----Original Message-----
From: Pieter Claerhout [mailto:Pieter.C...@creo.com]
Sent: 18 December 2003 14:43
To: 'Kamus of Kadizhar'; pytho...@python.org
Subject: RE: Searching docs (was Re: Logging)


You can search through the docs on:
http://web.pydoc.org/
and on
http://starship.python.net/crew/theller/pyhelp.cgi

cheers,


pieter

Creo
pieter claerhout | product support prinergy | tel: +32 2 352 2511 |
pieter.c...@creo.com | www.creo.com

IMAGINE CREATE BELIEVE(tm)


-----Original Message-----
From: Kamus of Kadizhar [mailto:y...@NsOeSiPnAeMr.com]
Sent: 18 December 2003 14:20
To: pytho...@python.org
Subject: Searching docs (was Re: Logging)


On Thu, 18 Dec 2003 23:40:33 +1100, Anthony Baxter wrote:

> Did you look in the logging documentation? At the end of the
> current docs, there's a simple example:

Missed that.

Is there a search on python.org that only searches docs? That would be
really helpful.... I keep coming up with gobs of irrelevant stuff on my
searches.

I keep missing simple stuff like that.

-Kamus
--
http://mail.python.org/mailman/listinfo/python-list

--
http://mail.python.org/mailman/listinfo/python-list

Pieter Claerhout

unread,
Dec 18, 2003, 8:43:12 AM12/18/03
to Kamus of Kadizhar, pytho...@python.org

Brett g Porter

unread,
Dec 18, 2003, 10:00:05 AM12/18/03
to
Pieter Claerhout wrote:
> You can search through the docs on:
> http://web.pydoc.org/

You can also torque up pydoc as a local http server by starting it with
the command line

python pydoc.py -p <port#>

...then point your browser to http://localhost:<port#>

Running pydoc locally has the advantage that it also lets you poke
through all the python modules and packages that are on your system. It
has the other advantage that it encourages you (well, me, anyway) to
write better docstrings...

The disadvantage is that it doesn't offer a search facility. Perhaps
some combination of pydoc and LuPy wouldn't be too hard to make happen...

Skip Montanaro

unread,
Dec 18, 2003, 10:38:35 AM12/18/03
to Kamus of Kadizhar, pytho...@python.org

Kamus> On Thu, 18 Dec 2003 23:40:33 +1100, Anthony Baxter wrote:
>> Did you look in the logging documentation? At the end of the
>> current docs, there's a simple example:

Kamus> Missed that.

Kamus> Is there a search on python.org that only searches docs? That
Kamus> would be really helpful.... I keep coming up with gobs of
Kamus> irrelevant stuff on my searches.

I've been meaning to put together some Google tips for python.org. Your
plea goaded me into action. The beginnings are here:

http://www.python.org/cgi-bin/moinmoin/GoogleTips

Many more are possible based upon the many mailing lists and documents the
site contains. Feel free to add to what's there.

Skip

0 new messages