CMS.debug(Throwable e); stack trace suppressed?
Hi, It seems that with the change in logging backend, calls to CMS.debug(Throwable e) no longer print the stack trace. The name of the exception is printed by the error message has been suppressed. I couldn't work out why this is happening but in my working tree I'm carrying the below change to get the stack traces back. Not sure if it's a "proper" way to fix it but it's doing the trick. Cheers, Fraser diff --git a/base/server/cmscore/src/com/netscape/cmscore/util/Debug.java b/base/server/cmscore/src/com/netscape/cmscore/util/Debug.java index 21e964c1a..135ca75bc 100644 --- a/base/server/cmscore/src/com/netscape/cmscore/util/Debug.java +++ b/base/server/cmscore/src/com/netscape/cmscore/util/Debug.java @@ -20,6 +20,9 @@ package com.netscape.cmscore.util; import java.util.Hashtable; import java.util.StringTokenizer; +import java.io.StringWriter; +import java.io.PrintWriter; + import org.dogtagpki.util.logging.PKILogger; import com.netscape.certsrv.apps.CMS; @@ -167,7 +170,16 @@ public class Debug if (!TRACE_ON) return; - CMS.logger.warn(e.getMessage(), e); + /* + String msg = e.getMessage(); // may be null + if (msg == null) + msg = e.toString(); + CMS.logger.warn(msg, e); + */ + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + e.printStackTrace(pw); + CMS.logger.warn(sw.toString()); } /**
On Fri, Mar 09, 2018 at 07:02:23PM +1000, Fraser Tweedale wrote:
Hi,
It seems that with the change in logging backend, calls to CMS.debug(Throwable e) no longer print the stack trace. The name of the exception is printed by the error message has been suppressed.
I couldn't work out why this is happening but in my working tree I'm carrying the below change to get the stack traces back. Not sure if it's a "proper" way to fix it but it's doing the trick.
Another thing I just remembered to mention: when the day rolls over the debug log starts going to stdout/journal(?), instead of a file with the new date. I have to restart the server to get it logging to the expected file after the day changes. Cheers, Fraser
----- Original Message -----
Another thing I just remembered to mention: when the day rolls over the debug log starts going to stdout/journal(?), instead of a file with the new date. I have to restart the server to get it logging to the expected file after the day changes.
Not quite sure about this. I'll need to take a closer look. -- Endi S. Dewata
Hi Fraser, Yeah, there's a bug in the message formatter. Could you take a look at this patch? https://review.gerrithub.io/#/c/403387/ Here's some documentation (still work in progress): http://pki.fedoraproject.org/wiki/PKI_10.6_Logging_Improvements Thanks! -- Endi S. Dewata ----- Original Message -----
Hi,
It seems that with the change in logging backend, calls to CMS.debug(Throwable e) no longer print the stack trace. The name of the exception is printed by the error message has been suppressed.
I couldn't work out why this is happening but in my working tree I'm carrying the below change to get the stack traces back. Not sure if it's a "proper" way to fix it but it's doing the trick.
Cheers, Fraser
diff --git a/base/server/cmscore/src/com/netscape/cmscore/util/Debug.java b/base/server/cmscore/src/com/netscape/cmscore/util/Debug.java index 21e964c1a..135ca75bc 100644 --- a/base/server/cmscore/src/com/netscape/cmscore/util/Debug.java +++ b/base/server/cmscore/src/com/netscape/cmscore/util/Debug.java @@ -20,6 +20,9 @@ package com.netscape.cmscore.util; import java.util.Hashtable; import java.util.StringTokenizer;
+import java.io.StringWriter; +import java.io.PrintWriter; + import org.dogtagpki.util.logging.PKILogger;
import com.netscape.certsrv.apps.CMS; @@ -167,7 +170,16 @@ public class Debug if (!TRACE_ON) return;
- CMS.logger.warn(e.getMessage(), e); + /* + String msg = e.getMessage(); // may be null + if (msg == null) + msg = e.toString(); + CMS.logger.warn(msg, e); + */ + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + e.printStackTrace(pw); + CMS.logger.warn(sw.toString()); }
/**
On Fri, Mar 09, 2018 at 11:00:50PM -0500, Endi Sukma Dewata wrote:
Hi Fraser,
Yeah, there's a bug in the message formatter. Could you take a look at this patch? https://review.gerrithub.io/#/c/403387/
Here's some documentation (still work in progress): http://pki.fedoraproject.org/wiki/PKI_10.6_Logging_Improvements
Thanks!
Patch works and reads fine, so I'll merge that now. Thanks for the fix! Cheers, Fraser
-- Endi S. Dewata
----- Original Message -----
Hi,
It seems that with the change in logging backend, calls to CMS.debug(Throwable e) no longer print the stack trace. The name of the exception is printed by the error message has been suppressed.
I couldn't work out why this is happening but in my working tree I'm carrying the below change to get the stack traces back. Not sure if it's a "proper" way to fix it but it's doing the trick.
Cheers, Fraser
diff --git a/base/server/cmscore/src/com/netscape/cmscore/util/Debug.java b/base/server/cmscore/src/com/netscape/cmscore/util/Debug.java index 21e964c1a..135ca75bc 100644 --- a/base/server/cmscore/src/com/netscape/cmscore/util/Debug.java +++ b/base/server/cmscore/src/com/netscape/cmscore/util/Debug.java @@ -20,6 +20,9 @@ package com.netscape.cmscore.util; import java.util.Hashtable; import java.util.StringTokenizer;
+import java.io.StringWriter; +import java.io.PrintWriter; + import org.dogtagpki.util.logging.PKILogger;
import com.netscape.certsrv.apps.CMS; @@ -167,7 +170,16 @@ public class Debug if (!TRACE_ON) return;
- CMS.logger.warn(e.getMessage(), e); + /* + String msg = e.getMessage(); // may be null + if (msg == null) + msg = e.toString(); + CMS.logger.warn(msg, e); + */ + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + e.printStackTrace(pw); + CMS.logger.warn(sw.toString()); }
/**
participants (2)
-
Endi Sukma Dewata -
Fraser Tweedale