     ))
 
 (defn log-root-dir
-  []
-  (let [appender (first (iterator-seq (.iteratorForAppenders (LoggerFactory/getLogger Logger/ROOT_LOGGER_NAME))))]
-    (if (and appender (instance? FileAppender appender))
+  "Given an appender name, as configured, get the parent directory of the appender's log file.
+
+Note that if anything goes wrong, this will throw an Error and exit."
+  [appender-name]
+  (let [appender (.getAppender (LoggerFactory/getLogger Logger/ROOT_LOGGER_NAME) appender-name)]
+    (if (and appender-name appender (instance? FileAppender appender))
       (.getParent (File. (.getFile appender)))
-      (.getCanonicalPath (File. (System/getProperty "storm.home") "logs")))))
+      (do
+        (throw
+         (Error. "Log viewer could not find configured appender, or the appender is not a FileAppender. Please check that the appender name configured in storm.yaml and cluster.xml agree."))
+        (System/exit 1)))))
 
-(defn log-page [file tail grep]
-  (let [path (.getCanonicalPath (File. (log-root-dir) file))
+(defn log-page [file tail grep root-dir]
+  (let [path (.getCanonicalPath (File. root-dir file))
         tail (if tail
                (min 10485760 (Integer/parseInt tail))
                10240)

  (handler/site log-routes)
 )

(defn start-logviewer [port]
  (run-jetty logapp {:port port}))

(defn -main []
  (let [conf (read-storm-config)]
    (start-logviewer (int (conf LOGVIEWER-PORT)))))


    ]))

(defroutes log-routes
  (GET "/log" [:as req & m]
       (log-template (log-page (:file m) (:tail m) (:grep m) (:log-root req))))
  (GET "/loglevel" [:as {cookies :cookies} & m]
       (log-template (log-level-page (:name m) (:level m))))
  (route/resources "/")
