Logging

John Abel john.abel at pa.press.net
Thu Dec 18 07:32:46 EST 2003


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

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?
>
> (Newbie Q, as you might guess...)
>
> -Kamus
>





More information about the Python-list mailing list