Scenario: watchdog logs contain errors/messages like these:

HTTP Status: 0; Message: Request failed: Connection refused; Response: ; Request: Unknown; Caller: ...

HTTP 0; Request failed: Connection refused in apachesolr_cron

No Solr instance available during indexing.

... and many more.

However, we have several environments; which one failed?

My proposal should add a reference to the environment, or the Solr URL (or both?) that would tell us exactly what environment was being invoked.

CommentFileSizeAuthor
#5 watchdog_logging_should-2609204-5.patch22.85 KBjanusman
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

janusman created an issue. See original summary.

jgrubb’s picture

Category: Task » Feature request

In apachesolr_cron, try changing this --

<?php
catch (Exception $e) {
      watchdog('Apache Solr', nl2br(check_plain($e->getMessage())) . ' in apachesolr_cron', NULL, WATCHDOG_ERROR);
    }
?>

to this --

<?php
catch (Exception $e) {
      watchdog('Apache Solr', nl2br(check_plain($e->getMessage())) . ' in apachesolr_cron. env_id: ' . $env_id, NULL, WATCHDOG_ERROR);
    }
?>

If that works, try submitting a patch back.

jgrubb’s picture

Status: Active » Needs review
jgrubb’s picture

Assigned: Unassigned » jgrubb
Status: Needs review » Active
janusman’s picture

Status: Active » Needs review
FileSize
22.85 KB

Here's a patch!

  • All watchdog() calls now add the environment ID as part of the message.
  • Pulls duplicated exception reporting code into new function apachesolr_log_exception()

Examples:

# This is a localhost Solr instance that is currently down:
$ drush solr-index --environment-id=localhost_8983

WD Apache Solr: Exception caught for function _drush_batch_worker() (line 150 of 
/home/alejandrogarza/.composer/vendor/drush/drush/commands/core/drupal/batch.inc), Environment localhost_8983: No Solr instance available during indexing.
# When getting a 403 from a remote Solr instance
$ drush solr-delete-index --environment-id=acquia_search_server_1

WD Apache Solr: Environment acquia_search_server_1; HTTP Status: 403; Message: Forbidden: Forbidden; Response: Apache Tomcat/6.0.35 - Error report HTTP      [error]
Status 403 - Access deniedtype Status reportmessage Access denieddescription Access to the specified resource (Access denied) has been forbidden.Apache
Tomcat/6.0.35; Request: POST /solr/{snip} HTTP/1.0
Content-Type: text/xml; charset=UTF-8
Cookie: { ... snip ... };
User-Agent: acquia_search/7.x
Host: useast1-c1.acquia-search.com
Content-Length: 43

hash:ih71re; Caller: AcquiaSearchService->_sendRawPost() (line 117 of
/home/alejandrogarza/Dev/drupal-modules/acquia_connector/acquia_search/Acquia_Search_Service.php)

As a side note, I did find that some functions do not care about environments and are just assuming the default environment. I tagged those with a comment (I can remove that to clean up the patch).

  • janusman authored 189aa04 on 7.x-1.x
    Issue #2609204 by janusman: Watchdog logging should indicate environment...
janusman’s picture

Assigned: jgrubb » janusman
Status: Needs review » Fixed

Fixed!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.