Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Cooperating with Apache Log Levels

by deprecated (Priest)
on Sep 25, 2001 at 21:21 UTC ( [id://114596]=perlquestion: print w/replies, xml ) Need Help??

deprecated has asked for the wisdom of the Perl Monks concerning the following question:

In /etc/httpd/httpd.conf (sorry, I'm a Darwin weenie for the moment), there's a line that looks something like this:
# Possible values include: debug, info, notice, warn, error, crit, LogLevel debug
Is it possible to create a conditional in my program to only print out debugging information if apache's loglevel is set to debug, warn, info, et cetera?

Thanks,
Brother dep.

--
Laziness, Impatience, Hubris, and Generosity.

Replies are listed 'Best First'.
Re: Cooperating with Apache Log Levels
by echo (Pilgrim) on Sep 25, 2001 at 21:37 UTC
    If your program is running under mod_perl, you can:

    use Apache::Log (); my $rlog = $r->log; $rlog->debug("You only see this if `LogLevel' is set to `debug'");
Re: Cooperating with Apache Log Levels
by arturo (Vicar) on Sep 25, 2001 at 21:49 UTC

    Apache::Log has a method for reading the loglevel, and it provides a number of methods that will log at certain LogLevels. It's for use with mod_perl, though, and I don't think you can use it with CGI (which is, I take it, a constraint here. If not, well, now you're golden =)

    You could also poke through the mod_perl code (the Apache::Log code isn't forthcoming) and figure out how it finds out. HTH.

    perl -e 'print "How sweet does a rose smell? "; chomp ($n = <STDIN>); +$rose = "smells sweet to degree $n"; *other_name = *rose; print "$oth +er_name\n"'
Re: Cooperating with Apache Log Levels
by perrin (Chancellor) on Sep 25, 2001 at 21:57 UTC
    As mentioned above, you should use Apache::Log if running under mod_perl. However, if what you're after is just a way to configure debugging from httpd.conf, you could simply set an environment variable right next to the line where you set LogLevel, and check that variable in your program when you print debugging info.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://114596]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-03-29 00:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found