You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Eric Moore <em...@cofs.net> on 2003/10/29 00:12:41 UTC

New User's First Steps

Having googl'd and read various faqs, cookbooks...

Site worked OK under CGI, but slowly -- on an old machine.

I have converted to mod_perl only using the Apache::Registry.  Application
uses CGI::App and HTML::Template.

Site runs faster now, but warnings disappeared from all logs.  [errors] show
up, but not warnings.

Any ideas on what I'm doing wrong?

Thanks, Eric.
 

httpd.conf
----------

LogLevel warn
PerlModule Apache::Registry
...

<VirtualHost _default_:443>
    DocumentRoot /var/www/pick6/
    ServerName www.yadda.com
    ServerAdmin g2@yeadda.com
    ErrorLog logs/error_log
    TransferLog logs/access_log
    ErrorLog /var/www/logs/pick6.error_log
    CustomLog /var/www/logs/pick6.access_log common
    Alias /perl/ /var/www/pick6/cgi-bin/
    ServerAlias yadda.com  *.yadda.com
    SSLEngine on
    SSLCertificateFile    /etc/ssl/server.crt
    SSLCertificateKeyFile /etc/ssl/private/server.key
    CustomLog logs/ssl_request_log \
    "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>     



Re: New User's First Steps

Posted by David Kaufman <da...@gigawatt.com>.
Eric Moore <em...@cofs.net> wrote:
> I have converted to mod_perl only using the Apache::Registry.
> Application uses CGI::App and HTML::Template.
>
> Site runs faster now, but warnings disappeared from all logs.
> [errors] show up, but not warnings.
>
> Any ideas on what I'm doing wrong?
> ...
> <VirtualHost _default_:443>
>     DocumentRoot /var/www/pick6/
>     ServerName www.yadda.com
>     ServerAdmin g2@yeadda.com
>     ErrorLog logs/error_log
>     TransferLog logs/access_log
>     ErrorLog /var/www/logs/pick6.error_log
>   # ...
> </VirtualHost>

could the two separate ErrorLog directives pointing at two different log
files be contributing to the problem?

-dave




Re: New User's First Steps

Posted by Jacob Fugal <ja...@fugal.net>.
Ged Haywood wrote:
> 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.

Except these (the ones you describe) are the errors that *do* get 
correctly passed to the virtual host's error log via the ErrorLog 
directive. The ones that there are no question about wanting them to go 
there (warn statements in my perl code, for instance) go to the 
wrong/inconvenient place.

Jacob Fugal


Re: New User's First Steps

Posted by Ged Haywood <ge...@www2.jubileegroup.co.uk>.
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.




Re: New User's First Steps

Posted by Eric Moore <em...@cofs.net>.
on 10/28/03 6:16 PM, Jacob Fugal at jacob@fugal.net wrote:
> Have you looked in the main error log (as opposed to
> /var/www/logs/pick6.error_log) for the warnings? I couldn't find my
> warns for a long time until I finally thought to check there. Errors
> (anything that causes an internal server error to display in the
> browser) show up in the per-host log, but the warn level STDERR all
> ignores the ErrorLog directive and goes to the main log. This may be
> what's happening to you.
> 
> I don't know how to fix it (if anyone else on here does, please let me
> know as well as Eric :), but in the meantime I just keep both error logs
> open. A pain, but bearable (at least for me).
> 
> Jacob Fugal

Sorry I didn't see your email until now.  YES.  This is exactly the same
problem I have.  

I saw a note about redirecting STDERR to the screen but nothing about
sending it to the virtual_host.error_log.  Anybody have a URL?  Thanks,
Eric.


Re: New User's First Steps

Posted by Jacob Fugal <ja...@fugal.net>.
Eric Moore wrote:
> Having googl'd and read various faqs, cookbooks...
> 
> Site worked OK under CGI, but slowly -- on an old machine.
> 
> I have converted to mod_perl only using the Apache::Registry.  Application
> uses CGI::App and HTML::Template.
> 
> Site runs faster now, but warnings disappeared from all logs.  [errors] show
> up, but not warnings.
> 
> Any ideas on what I'm doing wrong?
> 
> Thanks, Eric.
>  
> 
> httpd.conf
> ----------
> 
> LogLevel warn
> PerlModule Apache::Registry
> ...
> 
> <VirtualHost _default_:443>
>     DocumentRoot /var/www/pick6/
>     ServerName www.yadda.com
>     ServerAdmin g2@yeadda.com
>     ErrorLog logs/error_log
>     TransferLog logs/access_log
>     ErrorLog /var/www/logs/pick6.error_log
>     CustomLog /var/www/logs/pick6.access_log common
>     Alias /perl/ /var/www/pick6/cgi-bin/
>     ServerAlias yadda.com  *.yadda.com
>     SSLEngine on
>     SSLCertificateFile    /etc/ssl/server.crt
>     SSLCertificateKeyFile /etc/ssl/private/server.key
>     CustomLog logs/ssl_request_log \
>     "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
> </VirtualHost>     

Have you looked in the main error log (as opposed to 
/var/www/logs/pick6.error_log) for the warnings? I couldn't find my 
warns for a long time until I finally thought to check there. Errors 
(anything that causes an internal server error to display in the 
browser) show up in the per-host log, but the warn level STDERR all 
ignores the ErrorLog directive and goes to the main log. This may be 
what's happening to you.

I don't know how to fix it (if anyone else on here does, please let me 
know as well as Eric :), but in the meantime I just keep both error logs 
open. A pain, but bearable (at least for me).

Jacob Fugal



Re: New User's First Steps

Posted by Eric Moore <em...@cofs.net>.
on 10/28/03 6:24 PM, Stas Bekman at stas@stason.org wrote:

> Eric Moore wrote:
>> Having googl'd and read various faqs, cookbooks...
>> 
>> Site worked OK under CGI, but slowly -- on an old machine.
>> 
>> I have converted to mod_perl only using the Apache::Registry.  Application
>> uses CGI::App and HTML::Template.
>> 
>> Site runs faster now, but warnings disappeared from all logs.  [errors] show
>> up, but not warnings.
>> 
>> Any ideas on what I'm doing wrong?
> 
> Try adding:
> 
> PerlWarn On

Thanks. 

After playing with a simple test script, I see the errors go to the
virtual_host.error_log, but warnings go to the  error_log.  Is this correct?

httpd: LogLevel warn
....
test.pl

print "Content-type: text/html\n\n";
print "mod_perl working\n";
warn "This is a warning";







Re: New User's First Steps

Posted by Stas Bekman <st...@stason.org>.
Eric Moore wrote:
> Having googl'd and read various faqs, cookbooks...
> 
> Site worked OK under CGI, but slowly -- on an old machine.
> 
> I have converted to mod_perl only using the Apache::Registry.  Application
> uses CGI::App and HTML::Template.
> 
> Site runs faster now, but warnings disappeared from all logs.  [errors] show
> up, but not warnings.
> 
> Any ideas on what I'm doing wrong?

Try adding:

PerlWarn On

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