Error Log समझना
In this page:
यह कहाँ रहता है
Ubuntu/Debian पर default error log /var/log/apache2/error.log है और RHEL-family systems पर /var/log/httpd/error_log। access log की तरह, individual VirtualHosts अपना खुद ErrorLog से define कर सकते हैं (और single-site server से आगे किसी भी चीज़ के लिए करना चाहिए)।
LogLevel
LogLevel control करता है कि कितनी detail लिखी जाती है, कम से ज़्यादा verbose तक: emerg, alert, crit, error, warn, notice, info, debug। default warn production के लिए एक reasonable baseline है; debug कहीं ज़्यादा noisy है और मुख्य रूप से किसी specific problem को actively troubleshoot करते समय useful है, फिर बाद में वापस नीचे कर दिया जाता है।
वहाँ आपको Actually क्या दिखेगा
Startup problems (एक config syntax error, load होने में fail हुआ module, पहले से इस्तेमाल में एक port), permission errors (Apache का user उसे serve करने को कही गई file पढ़ नहीं सकता), PHP fatal errors और stack traces (अगर display_errors off है, जैसा production में होना चाहिए, तो यही *इकलौती* जगह है जहाँ वे दिखते हैं), और mod_rewrite का अपना rewrite-log-equivalent debug output जब LogLevel में rewrite:trace शामिल हो, यह सब यहीं आता है।
tail -f करें और page reload करें -- असली underlying error लगभग हमेशा वहीं बैठा होता है।एक Config Change Debug करने के लिए Error Log इस्तेमाल करना
अगर systemctl restart apache2 fail होता है, systemctl status apache2 अक्सर सिर्फ एक truncated summary दिखाता है -- पूरी detail (कौन सी directive, कौन सी file, कौन सी line) लगभग हमेशा error log की सबसे recent lines में होती है, यही कारण है कि इसे check करना आमतौर पर एक failed restart के बाद का अगला step है।
उदाहरण: Per-site error log and LogLevel
<VirtualHost *:80>
ServerName example.com
ErrorLog /var/log/apache2/example.com-error.log
LogLevel warn
</VirtualHost>
{# Flagged by hand after confirming a runner can't handle this example
(a shell command / go.mod file stored as a TopicExample, a language
feature the configured runner version doesn't support, or output
that blows a runner's sandbox limit) -- see TopicExample.norun.
Never render the run button for these, regardless of language,
since it would just fail at execute_code (or worse, hang the
Judge0 queue on a submission that can never finish cleanly). #}
- एक failed restart के बाद सिर्फ
systemctl statuscheck करके रुक जाना, error log में intezar कर रही ज़्यादा detailed explanation miss करते हुए। - production को
LogLevel debugपर हमेशा के लिए on छोड़कर चलाना, ज़रूरत से कहीं ज़्यादा noise generate करते हुए और real problems को scan करना मुश्किल बनाते हुए। - यह न समझना कि
display_errorsoff (production के लिए correct) होने पर भी PHP/application errors error log में जाते रहते हैं -- वे browser में सिर्फ invisible हैं, पूरी तरह gone नहीं।
Chapter Quiz — Complete all 4 topics to unlock
0/4 topics done
Complete these topics first: