Logging

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kamus of Kadizhar

    Logging

    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

    #2
    Re: Logging

    Try this. It records anything Warning and above.

    logFacility = logging.getLogg er( "MyApp" )
    logFile = logging.FileHan dler( "LogFile.lo g" )
    logFormat = logging.Formatt er( '%(asctime)s %(levelname)s
    %(message)s' )
    logFile.setForm atter( logFormat )
    logFacility.add Handler( logFile )
    logFacility.set Level( logging.WARNING )

    logFacility.inf o( "Starting Up" )
    **

    HTH

    John

    Kamus of Kadizhar wrote:
    [color=blue]
    > 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
    >[/color]

    Comment

    • Anthony Baxter

      #3
      Re: Logging

      [color=blue][color=green][color=darkred]
      >>> Kamus of Kadizhar wrote[/color][/color]
      > 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?[/color]

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



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


      Comment

      • Kamus of Kadizhar

        #4
        Searching docs (was Re: Logging)

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

        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

        Comment

        • Gerrit Holl

          #5
          Re: Searching docs (was Re: Logging)

          Kamus of Kadizhar wrote:[color=blue][color=green]
          > > Did you look in the logging documentation? At the end of the
          > > current docs, there's a simple example:[/color]
          >
          > Missed that.[/color]
          [color=blue]
          > 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.[/color]

          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:


          Comment

          • Skip Montanaro

            #6
            Re: Searching docs (was Re: Logging)


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

            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:



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

            Skip

            Comment

            Working...