Bug 8505

Summary: LOG4J - No stacktrace on unix platform
Product: Log4j - Now in Jira Reporter: fabrice claes <fabrice.claes>
Component: OtherAssignee: log4j-dev <log4j-dev>
Severity: major CC: espen
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: source
Output on windows
Example that solves the stacktrace problem

Description fabrice claes 2002-04-25 09:25:28 UTC

I received different output if my code runs on a windows platform or on an unix 

Here is the configuration file that i use :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

	<appender name="console" class="org.apache.log4j.ConsoleAppender">
		<param name="target" value="System.out"/>
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="[%d{dd/MM/yy 
HH:mm:ss,SSS} %C{1}:%M:%L] %m%n"/>
		<priority value="info"/>
		<appender-ref ref="console"/>


The code that generates the log :

public class TagUtils {

	private static final Category cat = Category.getInstance

	public static String getExceptionUserMessage(Exception e) {
		cat.info("Detail of that exception is : " + e.toString(),e);


The output that i received on windows platform :

[24/04/02 10:58:32,037 TagUtils:getExceptionUserMessage:115] Detail of that 
exception is : java.lang.NullPointerException
	at java.util.Hashtable.containsKey(Hashtable.java:299)
	at com.banksys.controller.TreeController.uniqueId
	at com.banksys.controller.TreeController.makeTree
	at com.banksys.controller.TreeController.generateTree
	at java.lang.reflect.Method.invoke(Native Method)
	at com.banksys.controller.BanksysServlet.doIt(BanksysServlet.java:151)
	at com.banksys.controller.BanksysServlet.doGet(BanksysServlet.java:101)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:195)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:309)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
	at com.evermind.server.http.ServletRequestDispatcher.invoke
	at com.evermind.server.http.ServletRequestDispatcher.include
	at com.evermind.server.http.GetParametersRequestDispatcher.include
	at oracle.jsp.runtime.OraclePageContext.include
	at _businessbeat._TreeBuilder._jspService(_TreeBuilder.java:52)
	at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
	at oracle.jsp.app.JspApplication.dispatchRequest
	at oracle.jsp.JspServlet.doDispatch(JspServlet.java:265)
	at oracle.jsp.JspServlet.internalService(JspServlet.java:184)
	at oracle.jsp.JspServlet.service(JspServlet.java:154)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
	at com.evermind.server.http.ServletRequestDispatcher.invoke
	at com.evermind.server.http.ServletRequestDispatcher.forwardInternal
	at com.evermind.server.http.HttpRequestHandler.processRequest
	at com.evermind.server.http.HttpRequestHandler.run
	at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:62)

The output i received on unix platform :

[24/04/2002 09:40:01,444 getExceptionUserMessage (TagUtils:java:115) :115) (pc 
232] Detail of that exception is : java.lang.NullPointerException

So i received no stacktrace on the unix platform. The layout of the message is 
also not the same as on the windows platform.
What can i do to solve this problem?

Comment 1 Ceki Gulcu 2002-04-25 12:54:42 UTC
Printing exception is one of the basic features of log4j. I am marking this
bug as WORKSFORME unless you can reproduce it with a small program on your UNIX
platform. Which UNIX platform is it by the way?
Comment 2 fabrice claes 2002-04-25 14:26:07 UTC
Created attachment 1697 [details]
Comment 3 fabrice claes 2002-04-25 14:26:50 UTC
Created attachment 1698 [details]
Comment 4 fabrice claes 2002-04-25 14:27:43 UTC
The platform is Compaq tru64 unix v 5.1 on Alpha. I reproduced the problem with 
a small program on the unix platform. I send you attached the program source, 
the configuration file and the outputs (on windows and on unix). Version of 
Log4J is 1.3.1
Comment 5 fabrice claes 2002-04-25 14:28:41 UTC
Created attachment 1699 [details]
Comment 6 fabrice claes 2002-04-25 14:29:14 UTC
Created attachment 1700 [details]
Output on windows
Comment 7 Ceki Gulcu 2002-05-07 21:30:07 UTC
What happens if you change 

<param name="ConversionPattern" value="[%d{dd/MM/yy HH:mm:ss,SSS} %C{1}:%M:%L] %


<param name="ConversionPattern" value="[%d{dd/MM/yy HH:mm:ss,SSS}] %m%n"/>

Can you please try that? Thanks, Ceki
Comment 8 Espen H. Kolstad 2002-05-23 09:51:12 UTC
Created attachment 1919 [details]
Example that solves the stacktrace problem
Comment 9 Espen H. Kolstad 2002-05-23 09:52:15 UTC

I've had the same problem! I've made a patch that works for Tru64 Unix 4.0F
Java versions 1.2.2, 1.3.1 and 1.4.0b

The problem lies in 
or more accurate the PrintWriter defined in 
org.apache.log4j.spi.ThrowableInformation's source file.

Check attachment (id=1919)

Comment 10 Ceki Gulcu 2002-05-24 12:26:07 UTC
Looking at your implementation of ThrowableInformation, the major
difference I see is that you are implementing the various write
methods of PrintWriter such as

  write(char[] chars)
  write(char[] chars, int off, int len)
  write(String s, int off, int len)
  write(String s)

Are you sure these methods are being called? Are all them called? If
not which ones are not?

Is the println() method ever called?

I don't think using ListArray is of fundamental importance in fixing
this bug. Do you?

Thank you for your assistance in fixing this bug, Ceki

Comment 11 Espen H. Kolstad 2002-05-24 12:52:03 UTC
I made quite a while ago so I can't remember which of the methods that are 
called, but I think it is:  write(String)

The println() I'm not sure of, sorry!

You're right, ArrayList was just what I used. It has nothing to do with the 

Comment 12 Ceki Gulcu 2002-10-09 00:31:48 UTC
This bug was fixed in log4j 1.2.3 or so.