Cindy Turlington
Cindy Turlington

Reputation: 2527

log file that shows CGI errors on GNU/Linux

I was unable to locate the log file that shows, say, "file not found" from a cgi script.

I know it probably is under /var/log, but a global find yields nothing, may be the file is readable by root only?

$ uname -a
Linux boxXXX.bluehost.com 3.12.35.1418668052 #1 SMP Wed Dec 17 20:04:02 CST 2014 x86_64 x86_64 x86_64 GNU/Linux

Upvotes: 2

Views: 6921

Answers (4)

John Fro
John Fro

Reputation: 1

CGI PHP scripts do not use Apache to run, so their errors do not appear in Apache error logs. You can do 2>&1 to send them to stdout.

Upvotes: 0

David C. Rankin
David C. Rankin

Reputation: 84632

Since the message was generated as a result of a call to the apache webserver, any error written to stderr (not stdout) by the cgi script will be recorded in the apache Error Log (see: Error Log ) To read/grep/whatever the error log, you must have sufficient read permission to both the log directory and the log file.

The log file can be in one of a number of locations. (usually in /var/log/httpd or /var/log/apache depending on distro) and usually as (error_log in linux or error.log in windows/OS2). Both are controlled by the ErrorLog directive in httpd.conf.

If you have read access to the log, you can simply grep 'file not found' /var/log/httpd/error_log (or the correct name for your setup) to find the entries. If not, you will either need sudo or su access to read the file as root, or you will need to complain loudly to the sysadmin that you do not have sufficient access. If you have tried all of the above and still are having difficulty, leave a comment and I will look further into it.

You can also tailor the format for logging cgi errors through mod_cgi or equivalent. See: CGI Debugging

Upvotes: 1

Grégory Roche
Grégory Roche

Reputation: 172

The log file depends of your configuration. For example, with Apache 2.4 under Debian 8.0, you can have :

$ ls -l /var/log/apache2/error*
-rw-r----- 1 root adm  212 mai    7 19:20 error.log
...

You must be root or in the group adm for read the file /var/log/apache2/access.log.

If you looking for "string to find" in the file "/var/log/apache2/error.log", you can do some like that :

$ sudo grep "string to find" /var/log/apache2/error.log

Upvotes: 0

Roberto De Oliveira
Roberto De Oliveira

Reputation: 129

You should see logs from your web server, for example with Apache on Debian you should look /var/log/apache2/*.log

You can use grep recursively on /var/log as root

grep "file not found" -R /var/log/*

Upvotes: 0

Related Questions