ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> modperl
modperl
Re: New User's First Steps
by Ged Haywood other posts by this author
Oct 29 2003 11:49AM messages near this date
Re: New User's First Steps | Re: New User's First Steps
Hi there,

On Wed, 29 Oct 2003, Eric Moore wrote:

>  I saw a note about redirecting STDERR to the screen but nothing about
>  sending it to the virtual_host.error_log.

Do you really want to do that?  Some errors may have nothing to do
with a virtual host (no permission, no more filehandles, disc full...)
and are more appropriate to the main server error_log.

I normally log everything to STDERR, but in the log output I like to
put enough information to tell me what the report was about. :)  That
could include for example something which identifies the virtual host,
if a virtual host was involved.  I might say:

print STDERR "$date_time $script $line $vhost $problem $other_useful_stuff\n"

and then split the log later if necessary with something like grep.

Actually on a larger project I might have a script especially for
logging errors which is called by the other scripts, passing any
parameters as necessary.  The log script would insert stuff which
it can deduce itself (like the date and time) without the need for
variables to be passed.  This kind of serious attention to logging
is probably overkill in the early stages of testing your ideas.

I tend to err on the side of verbosity in logs, then cut it down as
I get more confident. I have a conditional around the log statements
so that I can alter a variable somewhere to change the verbosity of
the logging.  Sometimes I'll comment out a log statement but rarely
will I delete, even if things have been running fine for years.

You might want to play with logging through the request or server
objects, using the $r-> warn() or $r->server->warn() methods.  See
chapter 9 of the Eagle Book, "Logging Methods" and chapter 16 of the
mod_perl Cookbook.  Details on the mod_perl website.

There are several logging modules on CPAN and you can use Apache's
flexible logging facilites too, for example you can log to a pipe and
do whatever you want on the fly.  Be careful with logging, performance
and security may be involved.  It's all in the docs.  Lots of docs. :)

73,
Ged.
Thread:
Eric Moore
David Kaufman
Jacob Fugal
Eric Moore
Ged Haywood
Jacob Fugal
Stas Bekman
Eric Moore

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved