Hi, I received different output if my code runs on a windows platform or on an unix platform. 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"/> </layout> </appender> <root> <priority value="info"/> <appender-ref ref="console"/> </root> </log4j:configuration> The code that generates the log : public class TagUtils { private static final Category cat = Category.getInstance (TagUtils.class); 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 java.lang.NullPointerException at java.util.Hashtable.containsKey(Hashtable.java:299) at com.banksys.controller.TreeController.uniqueId (TreeController.java:56) at com.banksys.controller.TreeController.makeTree (TreeController.java:157) at com.banksys.controller.TreeController.generateTree (TreeController.java:474) 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 (ServletRequestDispatcher.java:508) at com.evermind.server.http.ServletRequestDispatcher.include (ServletRequestDispatcher.java:94) at com.evermind.server.http.GetParametersRequestDispatcher.include (GetParametersRequestDispatcher.java:76) at oracle.jsp.runtime.OraclePageContext.include (OraclePageContext.java:488) at _businessbeat._TreeBuilder._jspService(_TreeBuilder.java:52) at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119) at oracle.jsp.app.JspApplication.dispatchRequest (JspApplication.java:389) 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 (ServletRequestDispatcher.java:508) at com.evermind.server.http.ServletRequestDispatcher.forwardInternal (ServletRequestDispatcher.java:177) at com.evermind.server.http.HttpRequestHandler.processRequest (HttpRequestHandler.java:576) at com.evermind.server.http.HttpRequestHandler.run (HttpRequestHandler.java:189) 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 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? Thanks.
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?
Created attachment 1697 [details] source
Created attachment 1698 [details] Output
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
Created attachment 1699 [details] Configuration
Created attachment 1700 [details] Output on windows
What happens if you change <param name="ConversionPattern" value="[%d{dd/MM/yy HH:mm:ss,SSS} %C{1}:%M:%L] % m%n"/> to <param name="ConversionPattern" value="[%d{dd/MM/yy HH:mm:ss,SSS}] %m%n"/> Can you please try that? Thanks, Ceki
Created attachment 1919 [details] Example that solves the stacktrace problem
Hello! 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 org.apache.log4j.spi.ThrowableInformation or more accurate the PrintWriter defined in org.apache.log4j.spi.ThrowableInformation's source file. Check attachment (id=1919) Espen
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
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 problem. Espen
This bug was fixed in log4j 1.2.3 or so.