Loading ...
Sorry, an error occurred while loading the content.
 

Custom Log files Under MP2

Expand Messages
  • Tofu Optimist
    I would like to append a small line of log information to a file on certain apache2 requests. For this application, I am very concerned about speed, so i m
    Message 1 of 5 , Sep 2, 2003
      I would like to append a small line of log information
      to a file on certain apache2 requests. For this
      application, I am very concerned about speed, so i'm
      looking for fast simple solutions.

      I could stuff the information in the error log as per
      http://perl.apache.org/docs/2.0/api/Apache/Log.html,
      and parse it out later off-line, but I'd prefer to
      reserve the error log for errors.

      I could stuff the information in the access log, and
      likewise pull out the data later off-line: how might I
      get data to the access_log?

      The most natural place to append the information would
      be a dedicated file. I've never written to a file
      from mod_perl, and don't know the correct idiom
      (flock? etc?) to do so.

      I'd appreciate any pointers to recipes, modules, etc.
      to show me the correct (fast, reliable) way to append
      to a file under MP2.

      Thanks!

      :)

      __________________________________
      Do you Yahoo!?
      Yahoo! SiteBuilder - Free, easy-to-use web site design software
      http://sitebuilder.yahoo.com


      --
      Reporting bugs: http://perl.apache.org/bugs/
      Mail list info: http://perl.apache.org/maillist/modperl.html
    • Stas Bekman
      ... You may want to spend some time with the mp2 docs first. http://perl.apache.org/docs/2.0/user/ Your particular question is answered at these locations:
      Message 2 of 5 , Sep 2, 2003
        Tofu Optimist wrote:
        > I would like to append a small line of log information
        > to a file on certain apache2 requests. For this
        > application, I am very concerned about speed, so i'm
        > looking for fast simple solutions.
        >
        > I could stuff the information in the error log as per
        > http://perl.apache.org/docs/2.0/api/Apache/Log.html,
        > and parse it out later off-line, but I'd prefer to
        > reserve the error log for errors.
        >
        > I could stuff the information in the access log, and
        > likewise pull out the data later off-line: how might I
        > get data to the access_log?
        >
        > The most natural place to append the information would
        > be a dedicated file. I've never written to a file
        > from mod_perl, and don't know the correct idiom
        > (flock? etc?) to do so.
        >
        > I'd appreciate any pointers to recipes, modules, etc.
        > to show me the correct (fast, reliable) way to append
        > to a file under MP2.

        You may want to spend some time with the mp2 docs first.
        http://perl.apache.org/docs/2.0/user/

        Your particular question is answered at these locations:
        http://perl.apache.org/docs/2.0/user/handlers/http.html#PerlLogHandler
        http://perl.apache.org/docs/2.0/user/handlers/server.html#Startup_Phases_Demonstration_Module

        As for flocking, I prefer to do that, even though there are claims that short
        writes are atomic. It's probably not the same on all io implementations.

        __________________________________________________________________
        Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
        http://stason.org/ mod_perl Guide ---> http://perl.apache.org
        mailto:stas@... http://use.perl.org http://apacheweek.com
        http://modperlbook.org http://apache.org http://ticketmaster.com



        --
        Reporting bugs: http://perl.apache.org/bugs/
        Mail list info: http://perl.apache.org/maillist/modperl.html
      • Geoffrey Young
        ... if speed is the concern, just stick to apache s native logging mechanism. see recipe 16.5, Conditional Logging in the mod_perl developer s cookbook:
        Message 3 of 5 , Sep 2, 2003
          Tofu Optimist wrote:
          > I would like to append a small line of log information
          > to a file on certain apache2 requests. For this
          > application, I am very concerned about speed, so i'm
          > looking for fast simple solutions.

          if speed is the concern, just stick to apache's native logging mechanism.

          see recipe 16.5, "Conditional Logging" in the mod_perl developer's cookbook:

          http://www.modperlcookbook.org/chapters/ch16.pdf

          in mod_perl 2.0, it's still $r->subprocess_env(), but you need to load
          APR::Table first.

          HTH

          --Geoff



          --
          Reporting bugs: http://perl.apache.org/bugs/
          Mail list info: http://perl.apache.org/maillist/modperl.html
        • Tofu Optimist
          Specifically, I d like to log certain image file requests (all files with .jpg, .gif, and .png extensions) to a custom log, image_log, logging IP, file, time,
          Message 4 of 5 , Sep 11, 2003
            Specifically,
            I'd like to log certain image file requests (all files
            with .jpg, .gif, and .png extensions) to a custom log,

            image_log, logging IP, file, time, status, bytes,
            referer, cookies, etc.

            I care about speed here.

            Would you suggest a native logging
            http://www.modperlcookbook.org/chapters/ch16.pdf

            or take this route
            http://perl.apache.org/docs/2.0/user/handlers/http.html#PerlLogHandler

            If the former, would you have any sample
            config code to illustrate?

            Thanks!

            -TO





            --- Geoffrey Young <geoff@...> wrote:
            >
            >
            > Tofu Optimist wrote:
            > > I would like to append a small line of log
            > information
            > > to a file on certain apache2 requests. For this
            > > application, I am very concerned about speed, so
            > i'm
            > > looking for fast simple solutions.
            >
            > if speed is the concern, just stick to apache's
            > native logging mechanism.
            >
            > see recipe 16.5, "Conditional Logging" in the
            > mod_perl developer's cookbook:
            >
            > http://www.modperlcookbook.org/chapters/ch16.pdf
            >
            > in mod_perl 2.0, it's still $r->subprocess_env(),
            > but you need to load
            > APR::Table first.
            >
            > HTH
            >
            > --Geoff
            >
            >
            >
            > --
            > Reporting bugs: http://perl.apache.org/bugs/
            > Mail list info:
            > http://perl.apache.org/maillist/modperl.html
            >


            __________________________________
            Do you Yahoo!?
            Yahoo! SiteBuilder - Free, easy-to-use web site design software
            http://sitebuilder.yahoo.com
          • Geoffrey Young
            ... native Apache routines, written in C, will always be faster, so if you can get the same functionality from native routines use them. it s the flexibility
            Message 5 of 5 , Sep 11, 2003
              Tofu Optimist wrote:
              > Specifically,
              > I'd like to log certain image file requests (all files
              > with .jpg, .gif, and .png extensions) to a custom log,
              >
              > image_log, logging IP, file, time, status, bytes,
              > referer, cookies, etc.
              >
              > I care about speed here.
              >
              > Would you suggest a native logging
              > http://www.modperlcookbook.org/chapters/ch16.pdf
              >
              > or take this route
              > http://perl.apache.org/docs/2.0/user/handlers/http.html#PerlLogHandler

              native Apache routines, written in C, will always be faster, so if you can
              get the same functionality from native routines use them. it's the
              flexibility mod_perl offers that makes it special :)

              >
              > If the former, would you have any sample
              > config code to illustrate?

              I think the conditional logging recipe is pretty descriptive. see also the
              CustomLog directive description in the apache documentation

              http://httpd.apache.org/docs-2.0/mod/directives.html

              FilesMatch might also help.

              --Geoff

              >
              > Thanks!
              >
              > -TO
              >
              >
              >
              >
              >
              > --- Geoffrey Young <geoff@...> wrote:
              >
              >>
              >>Tofu Optimist wrote:
              >>
              >>>I would like to append a small line of log
              >>
              >>information
              >>
              >>>to a file on certain apache2 requests. For this
              >>>application, I am very concerned about speed, so
              >>
              >>i'm
              >>
              >>>looking for fast simple solutions.
              >>
              >>if speed is the concern, just stick to apache's
              >>native logging mechanism.
              >>
              >>see recipe 16.5, "Conditional Logging" in the
              >>mod_perl developer's cookbook:
              >>
              >>http://www.modperlcookbook.org/chapters/ch16.pdf
              >>
              >>in mod_perl 2.0, it's still $r->subprocess_env(),
              >>but you need to load
              >>APR::Table first.
              >>
              >>HTH
              >>
              >>--Geoff
              >>
              >>
              >>
              >>--
              >>Reporting bugs: http://perl.apache.org/bugs/
              >>Mail list info:
              >>http://perl.apache.org/maillist/modperl.html
              >>
              >
              >
              >
              > __________________________________
              > Do you Yahoo!?
              > Yahoo! SiteBuilder - Free, easy-to-use web site design software
              > http://sitebuilder.yahoo.com
            Your message has been successfully submitted and would be delivered to recipients shortly.