You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2022/01/27 20:05:25 UTC

[GitHub] [logging-log4j2] ppkarwasz commented on a change in pull request #731: Adds a Tomcat lookup

ppkarwasz commented on a change in pull request #731:
URL: https://github.com/apache/logging-log4j2/pull/731#discussion_r793958070



##########
File path: log4j-appserver/src/main/java/org/apache/logging/log4j/appserver/tomcat/TomcatLookup.java
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.appserver.tomcat;
+
+import org.apache.juli.WebappProperties;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.lookup.StrLookup;
+
+/**
+ * Resolves the names specific to Tomcat's internal component structure. The
+ * names of the properties starting with {@code classloader.} are kept for
+ * compatibility with the original Tomcat JULI implementation.
+ */
+@Plugin(name = "tomcat", category = StrLookup.CATEGORY)
+public class TomcatLookup implements StrLookup {
+
+    private static final String SERVICE_LOGGER_FORMAT = "org.apache.catalina.core.ContainerBase.[%s]";
+    private static final String HOST_LOGGER_FORMAT = "org.apache.catalina.core.ContainerBase.[%s].[%s]";
+    private static final String CONTEXT_LOGGER_FORMAT = "org.apache.catalina.core.ContainerBase.[%s].[%s].[%s]";
+
+    @Override
+    public String lookup(String key) {
+        final ClassLoader cl = Thread.currentThread().getContextClassLoader();
+        if (cl instanceof WebappProperties) {
+            final WebappProperties props = (WebappProperties) cl;
+            switch (key) {

Review comment:
       Corrected, thanks.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org