Issue¶
How do I use the Drupal Watchdog log to troubleshoot?
Resolution¶
Note
Although this troubleshooting guide is intended for Acquia Cloud users, the information in this article may be helpful regarding websites hosted on other platforms.
The Drupal watchdog log records Drupal-related actions on your Drupal website. On Acquia Cloud, it contains data from all of your website's servers. You can download the most recent watchdog logs from the Cloud > Logs page. For more information about how to do so, see About Acquia Cloud logging.
If you're using another hosting platform, by default Drupal places the watchdog log at http://[site_URL]/admin/reports/dblog
.
Finding a specific page¶
If you're experiencing issues with a certain webpage on your website and need only the watchdog log messages for that particular webpage, you can obtain those messages with the following steps:
- Add a query string to the webpage's URL in your browser's address bar to make it unique, and to ensure that the web server will build a fresh page when receiving the request.
For example, if you want to debug this URL:
add a query string (such as ?x=1234
) to the end of the URL:
http://www.example.com/?x=1234
- Search your Apache access log for the query string that you used in the previous step.
Note
For each server, the Apache access log file is located at /var/log/sites/[site].[env]/logs/[servername]/[logname].log
.
You can find [site]
on the Cloud > Users and Keys page, and [servername]
on the Cloud > Servers page.
For example, the Apache access log for the Prod environment of a site named example
on a server named srv-25
would be:
/var/log/sites/example.prod/logs/srv-25/access.log
- Connect to your server using the
SSH
command.
- Change to the correct directory:
/var/log/sites/example.prod/logs/srv-25
- Use the following command to return the watchdog log messages for the website named
example
.
grep "?x=1234" drupal-watchdog.log
- If you need to search in these results, use the
grep
command again, like this:
grep "?x=1234" drupal-watchdog.log | grep "something else"
Finding by request id¶
If you have a particular request that seems to take an excessive amount of time to complete, you can search for it in the watchdog.log
Current day¶
You can cd
into your logs directory and use the UNIX tail
command to review the log as it processes, like this:
tail -f drupal-watchdog.log
If you tail the log while loading a page, you should see a line that contains a request_id
. After you have the request_id
, you can search the log with grep, which will display all of the log files this request_id
touched.
grep <requestIDhere> *.log
Previous days¶
Logs from previous days are gzipped. If you want to search through a gzipped log, you can do that with a command similar to the following:
zgrep <string> <logfile.gz>
After you have it, and you know what day you're searching for, you can zgrep through all of the gzipped files for that day, like this:
zgrep <string> *<date-filename>.gz
Memory consumption¶
Because excessive memory consumption can cause serious performance issues, you can also use the watchdog log file to help you determine where memory is being used excessively. For details about the Memory Profiler module and how to use it effectively to do this, see Logging using the Memory Profiler module.