Index: modules/statistics/statistics.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.install,v
retrieving revision 1.15
diff -u -r1.15 statistics.install
--- modules/statistics/statistics.install	3 Dec 2008 19:22:09 -0000	1.15
+++ modules/statistics/statistics.install	11 Dec 2008 16:38:39 -0000
@@ -75,6 +75,13 @@
         'not null' => FALSE,
         'description' => 'Internal path to page visited (relative to Drupal root.)',
       ),
+      'status_code' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => FALSE,
+        'default' => 0,
+        'description' => 'HTTP/1.1 Status Code',
+      ),
       'url' => array(
         'type' => 'text',
         'not null' => FALSE,
@@ -126,3 +133,19 @@
   db_change_field($ret, 'accesslog', 'url', 'url', array('type' => 'text', 'not null' => FALSE));
   return $ret;
 }
+
+/**
+ * Add field for the HTTP/1.1 Status Code.
+ */
+function statistics_update_7001() {
+  $ret = array();
+  $field = array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => FALSE,
+        'default' => 0,
+        'description' => 'HTTP/1.1 Status Code',
+  );
+  db_add_field($ret, 'accesslog', 'status_code', $field);
+  return $ret;
+}
Index: modules/statistics/statistics.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.module,v
retrieving revision 1.288
diff -u -r1.288 statistics.module
--- modules/statistics/statistics.module	9 Dec 2008 11:30:25 -0000	1.288
+++ modules/statistics/statistics.module	11 Dec 2008 16:38:39 -0000
@@ -47,7 +47,18 @@
 
   drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);
 
-  if (variable_get('statistics_count_content_views', 0)) {
+  switch ($title = strip_tags(drupal_get_title())) {
+    case t('Access denied'):
+      $status_code = 403;
+      break;
+  	case t('Page not found'):
+  		$status_code = 404;
+  		break;
+  	default:
+      $status_code = 200;
+  }
+
+  if ($status_code == 200 && variable_get('statistics_count_content_views', 0)) {
     // We are counting content views.
     if ((arg(0) == 'node') && is_numeric(arg(1)) && arg(2) == '') {
       // A node has been viewed, so update the node's counters.
@@ -67,8 +78,9 @@
   if (variable_get('statistics_enable_access_log', 0)) {
     // Log this page access.
     db_insert('accesslog')->fields(array(
-      'title' => strip_tags(drupal_get_title()),
+      'title' => $title,
       'path' => $_GET['q'],
+      'status_code' => $status_code,
       'url' => $_SERVER['HTTP_REFERER'],
       'hostname' => ip_address(),
       'uid' => $user->uid,
