Hello Remy,
with your Logger naming convention log4j not working
log4j:ERROR Parsing error on line 57 and column 99
log4j:ERROR Attribute value "org.apache.catalina.core.CatalinaBase.[].[localhost
].[Catalina]" of type ID must be a name.
With this logger naming convention it works fine:
org.apache.catalina.core.ContainerBase.Catalina.localhost.ROOT
Patch
Index: catalina/src/share/org/apache/catalina/core/ContainerBase.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ContainerBase.java,v
retrieving revision 1.36
diff -u -r1.36 ContainerBase.java
--- catalina/src/share/org/apache/catalina/core/ContainerBase.java 24 Jun 2004 15:28:27 -0000 1.36
+++ catalina/src/share/org/apache/catalina/core/ContainerBase.java 24 Jun 2004 16:49:23 -0000
@@ -36,18 +36,7 @@
import javax.naming.directory.DirContext;
import javax.servlet.ServletException;
-import org.apache.catalina.Cluster;
-import org.apache.catalina.Container;
-import org.apache.catalina.ContainerEvent;
-import org.apache.catalina.ContainerListener;
-import org.apache.catalina.Lifecycle;
-import org.apache.catalina.LifecycleException;
-import org.apache.catalina.LifecycleListener;
-import org.apache.catalina.Loader;
-import org.apache.catalina.Manager;
-import org.apache.catalina.Pipeline;
-import org.apache.catalina.Realm;
-import org.apache.catalina.Valve;
+import org.apache.catalina.*;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
import org.apache.catalina.util.LifecycleSupport;
@@ -1288,17 +1277,23 @@
}
String loggerName = null;
Container current = this;
+
while (current != null) {
- loggerName = "[" + current.getName() + "]"
+ String theName;
+ if(current instanceof StandardContext )
+ theName = "".equals(current.getName()) ? "ROOT" : current.getName();
+ else
+ theName= current.getName();
+ loggerName = theName
+ ((loggerName != null) ? ("." + loggerName) : "");
current = current.getParent();
}
logName = ContainerBase.class.getName() + "." + loggerName;
return logName;
- +
}
- +
// -------------------- JMX and Registration --------------------
protected String type;
protected String domain;
@@ -1310,7 +1305,7 @@
public ObjectName getJmxName() {
return oname;
}
- +
public String getObjectName() {
if (oname != null) {
return oname.toString();
@@ -1326,7 +1321,7 @@
}
if( parent instanceof StandardEngine ) {
domain=((StandardEngine)parent).getDomain();
- }
+ }
}
return domain;
}
@@ -1334,7 +1329,7 @@
public void setDomain(String domain) {
this.domain=domain;
}
- +
public String getType() {
return type;
}
@@ -1405,9 +1400,9 @@
Container context=null;
Container host=null;
Container servlet=null;
- +
StringBuffer suffix=new StringBuffer();
- +
if( container instanceof StandardHost ) {
host=container;
} else if( container instanceof StandardContext ) {
@@ -1421,7 +1416,7 @@
if( context!=null ) {
String path=((StandardContext)context).getPath();
suffix.append(",path=").append((path.equals("")) ? "/" : path);
- }
+ }
if( host!=null ) suffix.append(",host=").append( host.getName() );
if( servlet != null ) {
String name=container.getName();
I have fix this and it works
<logger name="org.apache.catalina.core.ContainerBase.Catalina.localhost.ROOT" additivity="false">
<level value="DEBUG"/>
<appender-ref ref="catalina"/>
</logger>
OK, I muss changed the bootstrap.jar META-INF dependcies to common-logging.jar instead commons-logging-api-jar
Copy common-logging.jar, log4j.jar and log4.xml to bin
delete commons-logging-api.jar
Change bootstrap.jar Manifest Manifest-Version: 1.0 Main-Class: org.apache.catalina.startup.Bootstrap Class-Path: jmx.jar commons-daemon.jar commons-logging.jar Specification-Title: Catalina Specification-Version: 1.0
Also change setclasspath.bat
set CLASSPATH=%JAVA_HOME%\lib\tools.jar;%BASEDIR%\bin\log4j.jar;%BASEDIR%\bin
..
Only thing that not nice with this patch is new StandardContext dependency!
regards Peter
Remy Maucherat schrieb:
Peter Rossbach wrote:
Hello Remy,
I have made a deeper look at the current cvs logger code stage:
1) ContainerBase.getLogger()
With first getLogger call the Log was build with a strange name!
public Log getLogger() {
if (logger != null) return (logger); String loggerName = null; Container current = this; while (current != null) { loggerName = "[" + current.getName() + "]" + ((loggerName != null) ? ("." + loggerName) : ""); current = current.getParent(); } logger = LogFactory.getLog("Tomcat." + loggerName); return (logger);
}
I think this can be done at init(). head Context logger Tomcat.[context].[host].[engine] Host.logger Tomcat.[host].[engine] Engine.Logger Tomcat.[engine]
Strange syntax...
other convention?: Context logger Tomcat.Logger.<engine>.<host>.<context> Tomcat.Logger.<engine>.<host>.ROOT Host.logger Tomcat.Logger.<engine>.<host> Engine.Logger Tomcat.Logger.<engine>
Current getLogger method not handle ROOT Context!
Well, it's going to be a blank String, so "[]". It's unique, so it's fine.
I think the prerfix should be o.a.ca.core.ContainerBase. (= the classname). "Logger" seems redundant (we know it's a Logger).
2) StandardContext.start() L4051.. String logName = "tomcat." + getParent().getName() + "." + ("".equals(getName()) ? "ROOT" : getName()) + ".Context"; log = org.apache.commons.logging.LogFactory.getLog(logName);
Hmm.
Why the complete init() phase goes to Log with name StandardContext.class and
after start all logging goes to "tomcat.<contextname>.Context" ?
This needs to go.
Rémy
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- J2EE Systemarchitekt und Tomcat Experte
http://objektpark.de/ http://www.webapp.de/
Am Josephsschacht 72, 44879 Bochum, Deutschland Telefon: (49) 234 9413228 Mobil: (49) 175 1660884 E-Mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]