NoOp logger is only used in StandardEngine so move it there
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 23 Nov 2010 22:48:21 +0000 (22:48 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 23 Nov 2010 22:48:21 +0000 (22:48 +0000)
Only log to containers that are available

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1038369 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/core/ContainerBase.java
java/org/apache/catalina/core/StandardEngine.java

index f45e3fc..14d9206 100644 (file)
@@ -1404,14 +1404,5 @@ public abstract class ContainerBase extends LifecycleMBeanBase
                 }
             }
         }
-
-    }
-
-    protected static final class NoopAccessLog implements AccessLog {
-
-        @Override
-        public void log(Request request, Response response, long time) {
-            // NOOP
-        }
     }
 }
index ae9c958..f702b50 100644 (file)
@@ -317,13 +317,14 @@ public class StandardEngine extends ContainerBase implements Engine {
                 // If we reached this point, this Engine can't have an AccessLog
                 // Look in the defaultHost
                 Host host = (Host) findChild(getDefaultHost());
-                if (host != null) {
+                if (host != null && host.getState().isAvailable()) {
                     defaultAccessLog = host.getAccessLog();
 
                     if (defaultAccessLog == null) {
                         // Try the ROOT context of default host
                         Context context = (Context) host.findChild("");
-                        if (context != null) {
+                        if (context != null &&
+                                context.getState().isAvailable()) {
                             defaultAccessLog = context.getAccessLog();
                         }
                     }
@@ -359,4 +360,12 @@ public class StandardEngine extends ContainerBase implements Engine {
         return "type=Engine";
     }
 
+    // ----------------------------------------------------------- Inner classes
+    protected static final class NoopAccessLog implements AccessLog {
+
+        @Override
+        public void log(Request request, Response response, long time) {
+            // NOOP
+        }
+    }
 }