How can I check Drupal log files?
Asked Answered
E

9

51

How can I check Drupal log files?

I'm using Ubuntu 10.10 + Apache2 + PHP 5.33 + MySQL and Drupal 7.

Eiland answered 21/6, 2011 at 6:24 Comment(0)
M
61

To view entries in Drupal's own internal log system (the watchdog database table), go to http://example.com/admin/reports/dblog. These can include Drupal-specific errors as well as general PHP or MySQL errors that have been thrown.

Use the watchdog() function to add an entry to this log from your own custom module.

When Drupal bootstraps it uses the PHP function set_error_handler() to set its own error handler for PHP errors. Therefore, whenever a PHP error occurs within Drupal it will be logged through the watchdog() call at admin/reports/dblog. If you look for PHP fatal errors, for example, in /var/log/apache/error.log and don't see them, this is why. Other errors, e.g. Apache errors, should still be logged in /var/log, or wherever you have it configured to log to.

Maros answered 23/6, 2011 at 2:10 Comment(1)
You could do that. The watchdog table has more than just the message, such as the module or library or whatever that threw it, a serialized array of data that you might want to store (information related to the error, outside of a message string), the location, the referrer, the currently logged in user, etc. So throwing watchdog('my_module', "Something broke.", $array_of_data) can be pretty useful for debugging.Maros
V
14

If you love the command line, you can also do this using drush with the watchdog show command:

drush ws

More information about this command available here:

https://drushcommands.com/drush-7x/watchdog/watchdog-show/

Vonnie answered 17/1, 2018 at 21:36 Comment(2)
how do you get it to show more logs. It only seems to show the most recent ones for me. Where as viewing in web admin pages shows more.Fixative
@Fixative If you review the docs linked above, you can use the --count to list a number of messages to return (default 10), or you can use the --tail to have it continuously print errors to the console.Vonnie
C
5

Make sure drush is installed (you may also need to make sure the dblog module is enabled) and use:

drush watchdog-show --tail

Available in drush v8 and below.

This will give you a live look at the logs from your console.

Clothesline answered 1/3, 2018 at 15:25 Comment(3)
The "--tail" option does not exist.Titivate
This is only available in drush 8 and below.Clothesline
Or drush ws will doRibbing
T
1

We came across many situation where we need to check error and error logs to figure out issue we are facing we can check by possibly following method:

1.) On blank screen Some time we got nothing but blank screen instead of our site or message written The website encountered an unexpected error. Please try again later , so we can Print Errors to the Screen by adding

error_reporting(E_ALL);

ini_set('display_errors', TRUE); 

ini_set('display_startup_errors', TRUE); 

in index.php at top.;

2.) We should enable optional core module for Database Logging at /admin/build/modules, and then we can check logs your_domain_name/admin/reports/dblog

3.) We can use drush command also to check logs drush watchdog-show it will show recent ten message

or if we want to continue showing logs with more information we can user
drush watchdog-show --tail --full.

4.) Also we can enable core Syslog module this module logs events of operating system of any web server.

Trifacial answered 15/3, 2018 at 10:1 Comment(0)
B
1

For drupal 9, you can access to your logs with drush , here some commands:

  • watchdog:delete (wd-del, wd-delete, wd) Delete watchdog log records.
  • watchdog:list (wd-list) Interactively filter the watchdog message listing.
  • watchdog:show (wd-show, ws) Show watchdog messages.
  • watchdog:show-one (wd-one) Show one log record by ID.
  • watchdog:tail (wd-tail, wt) Tail watchdog messages.

One more thing if your are not fan with commands, please in the Administrative menu, go to Reports > Recent log messages. On this page is a list of recent log messages which you can filter by type and severity.

but if your are professional you can configure ELK that's will give you all

Branum answered 26/10, 2021 at 10:50 Comment(0)
A
0

We can use drush command also to check logs drush watchdog-show it will show recent 10 messages.

or if we want to continue showing logs with more information we can user

drush watchdog-show --tail --full.
Adjunct answered 30/1, 2020 at 10:13 Comment(0)
T
0
MAMP/logs/php_error.log

Above all given option does not work go to the MAMP/logs/ check all type of log-like.

  1. mysql_error.log
  2. nginx_error.log
  3. apache_error.log
Tempi answered 4/8, 2021 at 18:34 Comment(0)
H
0

In Drupal, you can check the log files through the Drupal admin interface or by accessing the server files directly. Here are the steps for each method:

Through the Drupal admin interface:

Log in to your Drupal site as an administrator. Go to Reports > Recent log messages. This will show you a list of recent log entries, filtered by severity level and type.

By accessing server files:

Connect to your server via FTP or SFTP. Locate your Drupal installation directory. Look for the "logs" directory or server level /var/log. Open the log files you want to view.

Note: The location of the log files may vary depending on your Drupal installation and server configuration. You may need to consult your hosting provider or server administrator for help finding the logs.

Hazzard answered 4/2, 2023 at 14:18 Comment(0)
T
0

you can enable drupal database logging module and visit admin/reports/dblog to check logs

Timbuktu answered 23/3 at 23:27 Comment(1)
What does this add that hasn’t already been said previously?Assizes

© 2022 - 2024 — McMap. All rights reserved.