diff --git a/mod/resource/type/file/resource.class.php b/mod/resource/type/file/resource.class.php
index 10af2b7..a7c5ec9 100644
--- a/mod/resource/type/file/resource.class.php
+++ b/mod/resource/type/file/resource.class.php
@@ -377,6 +377,8 @@ class resource_file extends resource_base {
             exit;
         }
 
+        /// We can only get here once per resource, so add an entry to the log
+        add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id);
 
         /// Now check whether we need to display a frameset
 
@@ -474,11 +476,6 @@ class resource_file extends resource_base {
         }
 
 
-        /// We can only get here once per resource, so add an entry to the log
-
-        add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id);
-
-
         /// If we are in a frameset, just print the top of it
 
         if (!empty( $frameset ) and ($frameset == "top") ) {
