This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push:
new 7d7f83d2c9 Differentiate trace and debug log levels
7d7f83d2c9 is described below
commit 7d7f83d2c9527be5ef9237ebd6c222ef0abd27d1
Author: remm <[email protected]>
AuthorDate: Tue Feb 6 11:51:57 2024 +0100
Differentiate trace and debug log levels
---
java/org/apache/jasper/compiler/AntCompiler.java | 8 +--
java/org/apache/jasper/compiler/Compiler.java | 16 +++---
.../apache/jasper/compiler/JspRuntimeContext.java | 22 ++++----
java/org/apache/jasper/compiler/SmapUtil.java | 60 +++++++++++-----------
.../optimizations/ELInterpreterTagSetters.java | 4 +-
java/org/apache/jasper/servlet/JspServlet.java | 18 +++----
java/org/apache/jasper/servlet/TldScanner.java | 24 ++++-----
java/org/apache/tomcat/websocket/WsFrameBase.java | 4 +-
java/org/apache/tomcat/websocket/WsSession.java | 12 ++---
.../tomcat/websocket/WsWebSocketContainer.java | 8 +--
.../tomcat/websocket/server/WsFrameServer.java | 8 +--
webapps/docs/changelog.xml | 8 +++
12 files changed, 100 insertions(+), 92 deletions(-)
diff --git a/java/org/apache/jasper/compiler/AntCompiler.java
b/java/org/apache/jasper/compiler/AntCompiler.java
index 96d6275d7f..d22983d21a 100644
--- a/java/org/apache/jasper/compiler/AntCompiler.java
+++ b/java/org/apache/jasper/compiler/AntCompiler.java
@@ -80,8 +80,8 @@ public class AntCompiler extends Compiler {
}
if( options.getCompiler() != null ) {
- if( log.isDebugEnabled() ) {
- log.debug("Compiler " + options.getCompiler() );
+ if( log.isTraceEnabled() ) {
+ log.trace("Compiler " + options.getCompiler() );
}
project.setProperty("build.compiler", options.getCompiler() );
}
@@ -156,8 +156,8 @@ public class AntCompiler extends Compiler {
info.append(" cp=" + repository + "\n");
}
- if (log.isDebugEnabled()) {
- log.debug( "Using classpath: " +
System.getProperty("java.class.path") +
+ if (log.isTraceEnabled()) {
+ log.trace( "Using classpath: " +
System.getProperty("java.class.path") +
File.pathSeparator + classpath);
}
diff --git a/java/org/apache/jasper/compiler/Compiler.java
b/java/org/apache/jasper/compiler/Compiler.java
index 935c19ca1b..e0c1a5c766 100644
--- a/java/org/apache/jasper/compiler/Compiler.java
+++ b/java/org/apache/jasper/compiler/Compiler.java
@@ -259,9 +259,9 @@ public abstract class Compiler {
// to be GC'd and save memory.
ctxt.setWriter(null);
- if (log.isDebugEnabled()) {
+ if (log.isTraceEnabled()) {
t4 = System.currentTimeMillis();
- log.debug("Generated " + javaFileName + " total=" + (t4 - t1)
+ log.trace("Generated " + javaFileName + " total=" + (t4 - t1)
+ " generate=" + (t4 - t3) + " validate=" + (t2 - t1));
}
@@ -480,8 +480,8 @@ public abstract class Compiler {
}
if (targetLastModified != jspRealLastModified.longValue()) {
- if (log.isDebugEnabled()) {
- log.debug("Compiler: outdated: " + targetFile + " "
+ if (log.isTraceEnabled()) {
+ log.trace("Compiler: outdated: " + targetFile + " "
+ targetLastModified);
}
return true;
@@ -571,8 +571,8 @@ public abstract class Compiler {
try {
File javaFile = new File(ctxt.getServletJavaFileName());
- if (log.isDebugEnabled()) {
- log.debug("Deleting " + javaFile);
+ if (log.isTraceEnabled()) {
+ log.trace("Deleting " + javaFile);
}
if (javaFile.exists()) {
if (!javaFile.delete()) {
@@ -591,8 +591,8 @@ public abstract class Compiler {
public void removeGeneratedClassFiles() {
try {
File classFile = new File(ctxt.getClassFileName());
- if (log.isDebugEnabled()) {
- log.debug("Deleting " + classFile);
+ if (log.isTraceEnabled()) {
+ log.trace("Deleting " + classFile);
}
if (classFile.exists()) {
if (!classFile.delete()) {
diff --git a/java/org/apache/jasper/compiler/JspRuntimeContext.java
b/java/org/apache/jasper/compiler/JspRuntimeContext.java
index 88798b9d04..b684472abd 100644
--- a/java/org/apache/jasper/compiler/JspRuntimeContext.java
+++ b/java/org/apache/jasper/compiler/JspRuntimeContext.java
@@ -96,12 +96,12 @@ public final class JspRuntimeContext {
loader = this.getClass().getClassLoader();
}
- if (log.isDebugEnabled()) {
+ if (log.isTraceEnabled()) {
if (loader != null) {
-
log.debug(Localizer.getMessage("jsp.message.parent_class_loader_is",
+
log.trace(Localizer.getMessage("jsp.message.parent_class_loader_is",
loader.toString()));
} else {
-
log.debug(Localizer.getMessage("jsp.message.parent_class_loader_is",
+
log.trace(Localizer.getMessage("jsp.message.parent_class_loader_is",
"<none>"));
}
}
@@ -135,8 +135,8 @@ public final class JspRuntimeContext {
if (options.getMaxLoadedJsps() > 0) {
jspQueue = new FastRemovalDequeue<>(options.getMaxLoadedJsps());
- if (log.isDebugEnabled()) {
- log.debug(Localizer.getMessage("jsp.message.jsp_queue_created",
+ if (log.isTraceEnabled()) {
+ log.trace(Localizer.getMessage("jsp.message.jsp_queue_created",
"" +
options.getMaxLoadedJsps(), context.getContextPath()));
}
}
@@ -223,8 +223,8 @@ public final class JspRuntimeContext {
FastRemovalDequeue<JspServletWrapper>.Entry entry = jspQueue.push(jsw);
JspServletWrapper replaced = entry.getReplaced();
if (replaced != null) {
- if (log.isDebugEnabled()) {
-
log.debug(Localizer.getMessage("jsp.message.jsp_removed_excess",
+ if (log.isTraceEnabled()) {
+
log.trace(Localizer.getMessage("jsp.message.jsp_removed_excess",
replaced.getJspUri(),
context.getContextPath()));
}
unloadJspServletWrapper(replaced);
@@ -468,8 +468,8 @@ public final class JspRuntimeContext {
String path = cpath.toString() + cp;
- if(log.isDebugEnabled()) {
- log.debug("Compilation classpath initialized: " + path);
+ if(log.isTraceEnabled()) {
+ log.trace("Compilation classpath initialized: " + path);
}
return path;
}
@@ -580,8 +580,8 @@ public final class JspRuntimeContext {
JspServletWrapper jsw = (JspServletWrapper) wrapper;
synchronized (jsw) {
if (jsw.getLastUsageTime() < unloadBefore) {
- if (log.isDebugEnabled()) {
-
log.debug(Localizer.getMessage("jsp.message.jsp_removed_idle",
+ if (log.isTraceEnabled()) {
+
log.trace(Localizer.getMessage("jsp.message.jsp_removed_idle",
jsw.getJspUri(), context.getContextPath(),
"" + (now - jsw.getLastUsageTime())));
}
diff --git a/java/org/apache/jasper/compiler/SmapUtil.java
b/java/org/apache/jasper/compiler/SmapUtil.java
index 8495e6f15e..e06d1ea2c0 100644
--- a/java/org/apache/jasper/compiler/SmapUtil.java
+++ b/java/org/apache/jasper/compiler/SmapUtil.java
@@ -243,8 +243,8 @@ public class SmapUtil {
copy(4 + 2 + 2); // magic min/maj version
int constantPoolCountPos = genPos;
int constantPoolCount = readU2();
- if (log.isDebugEnabled()) {
- log.debug("constant pool count: " + constantPoolCount);
+ if (log.isTraceEnabled()) {
+ log.trace("constant pool count: " + constantPoolCount);
}
writeU2(constantPoolCount);
@@ -259,19 +259,19 @@ public class SmapUtil {
++constantPoolCount;
randomAccessWriteU2(constantPoolCountPos, constantPoolCount);
- if (log.isDebugEnabled()) {
- log.debug("SourceDebugExtension not found, installed at: "
+ sdeIndex);
+ if (log.isTraceEnabled()) {
+ log.trace("SourceDebugExtension not found, installed at: "
+ sdeIndex);
}
} else {
- if (log.isDebugEnabled()) {
- log.debug("SourceDebugExtension found at: " + sdeIndex);
+ if (log.isTraceEnabled()) {
+ log.trace("SourceDebugExtension found at: " + sdeIndex);
}
}
copy(2 + 2 + 2); // access, this, super
int interfaceCount = readU2();
writeU2(interfaceCount);
- if (log.isDebugEnabled()) {
- log.debug("interfaceCount: " + interfaceCount);
+ if (log.isTraceEnabled()) {
+ log.trace("interfaceCount: " + interfaceCount);
}
copy(interfaceCount * 2);
copyMembers(); // fields
@@ -279,16 +279,16 @@ public class SmapUtil {
int attrCountPos = genPos;
int attrCount = readU2();
writeU2(attrCount);
- if (log.isDebugEnabled()) {
- log.debug("class attrCount: " + attrCount);
+ if (log.isTraceEnabled()) {
+ log.trace("class attrCount: " + attrCount);
}
// copy the class attributes, return true if SDE attr found (not
copied)
if (!copyAttrs(attrCount)) {
// we will be adding SDE and it isn't already counted
++attrCount;
randomAccessWriteU2(attrCountPos, attrCount);
- if (log.isDebugEnabled()) {
- log.debug("class attrCount incremented");
+ if (log.isTraceEnabled()) {
+ log.trace("class attrCount incremented");
}
}
writeAttrForSDE(sdeIndex);
@@ -297,15 +297,15 @@ public class SmapUtil {
void copyMembers() {
int count = readU2();
writeU2(count);
- if (log.isDebugEnabled()) {
- log.debug("members count: " + count);
+ if (log.isTraceEnabled()) {
+ log.trace("members count: " + count);
}
for (int i = 0; i < count; ++i) {
copy(6); // access, name, descriptor
int attrCount = readU2();
writeU2(attrCount);
- if (log.isDebugEnabled()) {
- log.debug("member attr count: " + attrCount);
+ if (log.isTraceEnabled()) {
+ log.trace("member attr count: " + attrCount);
}
copyAttrs(attrCount);
}
@@ -318,16 +318,16 @@ public class SmapUtil {
// don't write old SDE
if (nameIndex == sdeIndex) {
sdeFound = true;
- if (log.isDebugEnabled()) {
- log.debug("SDE attr found");
+ if (log.isTraceEnabled()) {
+ log.trace("SDE attr found");
}
} else {
writeU2(nameIndex); // name
int len = readU4();
writeU4(len);
copy(len);
- if (log.isDebugEnabled()) {
- log.debug("attr len: " + len);
+ if (log.isTraceEnabled()) {
+ log.trace("attr len: " + len);
}
}
}
@@ -408,14 +408,14 @@ public class SmapUtil {
case 7 : // Class
case 8 : // String
case 16 : // MethodType
- if (log.isDebugEnabled()) {
- log.debug(i + " copying 2 bytes");
+ if (log.isTraceEnabled()) {
+ log.trace(i + " copying 2 bytes");
}
copy(2);
break;
case 15 : // MethodHandle
- if (log.isDebugEnabled()) {
- log.debug(i + " copying 3 bytes");
+ if (log.isTraceEnabled()) {
+ log.trace(i + " copying 3 bytes");
}
copy(3);
break;
@@ -426,15 +426,15 @@ public class SmapUtil {
case 4 : // Float
case 12 : // NameAndType
case 18 : // InvokeDynamic
- if (log.isDebugEnabled()) {
- log.debug(i + " copying 4 bytes");
+ if (log.isTraceEnabled()) {
+ log.trace(i + " copying 4 bytes");
}
copy(4);
break;
case 5 : // Long
case 6 : // Double
- if (log.isDebugEnabled()) {
- log.debug(i + " copying 8 bytes");
+ if (log.isTraceEnabled()) {
+ log.trace(i + " copying 8 bytes");
}
copy(8);
i++;
@@ -444,8 +444,8 @@ public class SmapUtil {
writeU2(len);
byte[] utf8 = readBytes(len);
String str = new String(utf8, "UTF-8");
- if (log.isDebugEnabled()) {
- log.debug(i + " read class attr -- '" + str + "'");
+ if (log.isTraceEnabled()) {
+ log.trace(i + " read class attr -- '" + str + "'");
}
if (str.equals(nameSDE)) {
sdeIndex = i;
diff --git a/java/org/apache/jasper/optimizations/ELInterpreterTagSetters.java
b/java/org/apache/jasper/optimizations/ELInterpreterTagSetters.java
index 5f9ce6c98a..9a15292b42 100644
--- a/java/org/apache/jasper/optimizations/ELInterpreterTagSetters.java
+++ b/java/org/apache/jasper/optimizations/ELInterpreterTagSetters.java
@@ -259,8 +259,8 @@ public class ELInterpreterTagSetters implements
ELInterpreter {
fnmapvar);
}
- if (log.isDebugEnabled()) {
- log.debug("Expression [" + expression + "], type [" +
expectedType.getName() + "], returns [" + result + "]");
+ if (log.isTraceEnabled()) {
+ log.trace("Expression [" + expression + "], type [" +
expectedType.getName() + "], returns [" + result + "]");
}
return result;
diff --git a/java/org/apache/jasper/servlet/JspServlet.java
b/java/org/apache/jasper/servlet/JspServlet.java
index 39cb7947df..e8bfe9aff9 100644
--- a/java/org/apache/jasper/servlet/JspServlet.java
+++ b/java/org/apache/jasper/servlet/JspServlet.java
@@ -317,13 +317,13 @@ public class JspServlet extends HttpServlet implements
PeriodicEventListener {
}
}
- if (log.isDebugEnabled()) {
- log.debug("JspEngine --> " + jspUri);
- log.debug("\t ServletPath: " + request.getServletPath());
- log.debug("\t PathInfo: " + request.getPathInfo());
- log.debug("\t RealPath: " + context.getRealPath(jspUri));
- log.debug("\t RequestURI: " + request.getRequestURI());
- log.debug("\t QueryString: " + request.getQueryString());
+ if (log.isTraceEnabled()) {
+ log.trace("JspEngine --> " + jspUri);
+ log.trace("\t ServletPath: " + request.getServletPath());
+ log.trace("\t PathInfo: " + request.getPathInfo());
+ log.trace("\t RealPath: " + context.getRealPath(jspUri));
+ log.trace("\t RequestURI: " + request.getRequestURI());
+ log.trace("\t QueryString: " + request.getQueryString());
}
try {
@@ -340,8 +340,8 @@ public class JspServlet extends HttpServlet implements
PeriodicEventListener {
@Override
public void destroy() {
- if (log.isDebugEnabled()) {
- log.debug("JspServlet.destroy()");
+ if (log.isTraceEnabled()) {
+ log.trace("JspServlet.destroy()");
}
rctxt.destroy();
diff --git a/java/org/apache/jasper/servlet/TldScanner.java
b/java/org/apache/jasper/servlet/TldScanner.java
index 4561739dc3..f79a9bf32b 100644
--- a/java/org/apache/jasper/servlet/TldScanner.java
+++ b/java/org/apache/jasper/servlet/TldScanner.java
@@ -243,12 +243,12 @@ public class TldScanner {
}
}
if (found) {
- if (log.isDebugEnabled()) {
-
log.debug(Localizer.getMessage("jsp.tldCache.tldInResourcePath", startPath));
+ if (log.isTraceEnabled()) {
+
log.trace(Localizer.getMessage("jsp.tldCache.tldInResourcePath", startPath));
}
} else {
- if (log.isDebugEnabled()) {
-
log.debug(Localizer.getMessage("jsp.tldCache.noTldInResourcePath", startPath));
+ if (log.isTraceEnabled()) {
+
log.trace(Localizer.getMessage("jsp.tldCache.noTldInResourcePath", startPath));
}
}
}
@@ -318,13 +318,13 @@ public class TldScanner {
}
}
if (found) {
- if (log.isDebugEnabled()) {
- log.debug(Localizer.getMessage("jsp.tldCache.tldInJar",
jarFileUrl.toString()));
+ if (log.isTraceEnabled()) {
+ log.trace(Localizer.getMessage("jsp.tldCache.tldInJar",
jarFileUrl.toString()));
}
} else {
foundJarWithoutTld = true;
- if (log.isDebugEnabled()) {
- log.debug(Localizer.getMessage(
+ if (log.isTraceEnabled()) {
+ log.trace(Localizer.getMessage(
"jsp.tldCache.noTldInJar", jarFileUrl.toString()));
}
}
@@ -374,13 +374,13 @@ public class TldScanner {
}
});
if (foundFileWithoutTld) {
- if (log.isDebugEnabled()) {
- log.debug(Localizer.getMessage("jsp.tldCache.tldInDir",
+ if (log.isTraceEnabled()) {
+ log.trace(Localizer.getMessage("jsp.tldCache.tldInDir",
file.getAbsolutePath()));
}
} else {
- if (log.isDebugEnabled()) {
- log.debug(Localizer.getMessage("jsp.tldCache.noTldInDir",
+ if (log.isTraceEnabled()) {
+ log.trace(Localizer.getMessage("jsp.tldCache.noTldInDir",
file.getAbsolutePath()));
}
}
diff --git a/java/org/apache/tomcat/websocket/WsFrameBase.java
b/java/org/apache/tomcat/websocket/WsFrameBase.java
index 3b82a90a00..e3199e219d 100644
--- a/java/org/apache/tomcat/websocket/WsFrameBase.java
+++ b/java/org/apache/tomcat/websocket/WsFrameBase.java
@@ -207,8 +207,8 @@ public abstract class WsFrameBase {
}
payloadLength = b & 0x7F;
state = State.PARTIAL_HEADER;
- if (getLog().isDebugEnabled()) {
- getLog().debug(sm.getString("wsFrame.partialHeaderComplete",
Boolean.toString(fin), Integer.toString(rsv),
+ if (getLog().isTraceEnabled()) {
+ getLog().trace(sm.getString("wsFrame.partialHeaderComplete",
Boolean.toString(fin), Integer.toString(rsv),
Integer.toString(opCode), Long.toString(payloadLength)));
}
return true;
diff --git a/java/org/apache/tomcat/websocket/WsSession.java
b/java/org/apache/tomcat/websocket/WsSession.java
index 602e14b671..907f93abc9 100644
--- a/java/org/apache/tomcat/websocket/WsSession.java
+++ b/java/org/apache/tomcat/websocket/WsSession.java
@@ -168,8 +168,8 @@ public class WsSession implements Session {
this.localEndpoint =
clientEndpointHolder.getInstance(getInstanceManager());
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("wsSession.created", id));
+ if (log.isTraceEnabled()) {
+ log.trace(sm.getString("wsSession.created", id));
}
}
@@ -267,8 +267,8 @@ public class WsSession implements Session {
this.localEndpoint = new PojoEndpointServer(pathParameters,
endpointInstance);
}
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("wsSession.created", id));
+ if (log.isTraceEnabled()) {
+ log.trace(sm.getString("wsSession.created", id));
}
}
@@ -653,8 +653,8 @@ public class WsSession implements Session {
return;
}
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("wsSession.doClose", id));
+ if (log.isTraceEnabled()) {
+ log.trace(sm.getString("wsSession.doClose", id));
}
// Flush any batched messages not yet sent.
diff --git a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
index 847c77f68c..b5fc142698 100644
--- a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
+++ b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
@@ -183,8 +183,8 @@ public class WsWebSocketContainer implements
WebSocketContainer, BackgroundProce
ClientEndpointConfig clientEndpointConfiguration, URI path,
Set<URI> redirectSet)
throws DeploymentException {
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("wsWebSocketContainer.connect.entry",
clientEndpointHolder.getClassName(), path));
+ if (log.isTraceEnabled()) {
+ log.trace(sm.getString("wsWebSocketContainer.connect.entry",
clientEndpointHolder.getClassName(), path));
}
boolean secure = false;
@@ -319,14 +319,14 @@ public class WsWebSocketContainer implements
WebSocketContainer, BackgroundProce
Future<Void> fHandshake = channel.handshake();
fHandshake.get(timeout, TimeUnit.MILLISECONDS);
- if (log.isDebugEnabled()) {
+ if (log.isTraceEnabled()) {
SocketAddress localAddress = null;
try {
localAddress = channel.getLocalAddress();
} catch (IOException ioe) {
// Ignore
}
- log.debug(sm.getString("wsWebSocketContainer.connect.write",
Integer.valueOf(request.position()),
+ log.trace(sm.getString("wsWebSocketContainer.connect.write",
Integer.valueOf(request.position()),
Integer.valueOf(request.limit()), localAddress));
}
writeRequest(channel, request, timeout);
diff --git a/java/org/apache/tomcat/websocket/server/WsFrameServer.java
b/java/org/apache/tomcat/websocket/server/WsFrameServer.java
index c0eb9e8b62..fb65a3ae05 100644
--- a/java/org/apache/tomcat/websocket/server/WsFrameServer.java
+++ b/java/org/apache/tomcat/websocket/server/WsFrameServer.java
@@ -57,8 +57,8 @@ public class WsFrameServer extends WsFrameBase {
* @throws IOException if an I/O error occurs while processing the
available data
*/
private void onDataAvailable() throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("wsFrameServer.onDataAvailable");
+ if (log.isTraceEnabled()) {
+ log.trace("wsFrameServer.onDataAvailable");
}
if (isOpen() && inputBuffer.hasRemaining() && !isSuspended()) {
// There might be a data that was left in the buffer when
@@ -79,8 +79,8 @@ public class WsFrameServer extends WsFrameBase {
} else if (read == 0) {
return;
}
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("wsFrameServer.bytesRead",
Integer.toString(read)));
+ if (log.isTraceEnabled()) {
+ log.trace(sm.getString("wsFrameServer.bytesRead",
Integer.toString(read)));
}
processInputBuffer();
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 2122baaaed..d4f0d0697f 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -149,6 +149,10 @@
<bug>68546</bug>: Generate optimal size and types for JSP imports maps,
as suggested by John Engebretson. (remm)
</fix>
+ <fix>
+ Review usage of debug logging and downgrade trace or data dumping
+ operations from debug level to trace. (remm)
+ </fix>
</changelog>
</subsection>
<subsection name="WebSocket">
@@ -157,6 +161,10 @@
Correct a regression in the fix for <bug>66508</bug> that could cause
an
<code>UpgradeProcessor</code> leak in some circumstances. (markt)
</fix>
+ <fix>
+ Review usage of debug logging and downgrade trace or data dumping
+ operations from debug level to trace. (remm)
+ </fix>
</changelog>
</subsection>
</section>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]