logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Smith <paul.sm...@lawlex.com.au>
Subject Re: I am not getting stack trace from logger.error("error",e)?
Date Mon, 08 Dec 2003 21:11:27 GMT
Depends how you log your stacktrace.  If you log like this:

private static final Logger LOG = Logger.getLogger(.....);

.......
try {

}
catch(Exception e) {
  LOG.error(e);
}

Then you WILL only get the error message without the rest of the stack
trace.  The reason is that the exception is going to the
loggers.error(Object) method, and Log4j is simply calling the
.toString() on the Exception object.

This is a common mistake, and I've forgotten this several times myself. 

What you really need to do is:

LOG.error("An error happened here", e);

This will ensure that the full stacktrace is output (assuming that the
JDK 1.4.2 doesn't still get you)

cheers,

Paul Smith

On Tue, 2003-12-09 at 07:23, struts wrote:
> I am also getting the similiar problem. Just I was able to see the stack
> trace in the console, but in the database, I can just see the error message
> without stack trace. Attached is my log4j.xml file. Anybody knows why?
> 
> Thanks.
> 
> Song
> 
> "Robert Augustyn" <augustynr@yahoo.com> wrote in message
> news:20031128001915.1794.qmail@web41503.mail.yahoo.com...
> > Paul,
> > Thanks, I am running 1.4.2 vm and it does not look
> > like it's fixed...
> > It is real pain!.
> > robert
> >
> > -----Original Message-----
> > From: Paul Smith [mailto:paul.smith@lawlex.com.au]
> > Sent: Thursday, November 27, 2003 7:02 PM
> > To: Log4J Users List
> > Subject: RE: I am not getting stack trace from
> > logger.error("error",e)?
> >
> >
> > On Fri, 2003-11-28 at 10:45, Robert Augustyn wrote:
> >
> > > Hi Ceki,
> >
> > > I am getting just one line like:
> >
> > > Java.NullPointerException:
> >
> >
> >
> > This maybe only a very slight possibility, but I have
> > seen exactly what
> >
> > you are describing in our production environment when
> > we are using the
> >
> > -server option under the Sun 1.4.2 JDK under Linux (no
> > JBoss though).
> >
> > Just a single line with no more information.
> >
> >
> >
> > See this bug:
> >
> > http://developer.java.sun.com/developer/bugParade/bugs/4761344.html
> >
> >
> >
> > They say it is fixed in 1.4.2, and while it does not
> > happen with the
> >
> > frequency it used to, it's one to look out for.  Not
> > using the -server
> >
> > option seems to help, although you lose some
> > performance there.
> >
> >
> >
> > cheers,
> >
> >
> >
> > Paul Smith
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> >
> > To unsubscribe, e-mail:
> > log4j-user-unsubscribe@jakarta.apache.org
> >
> > For additional commands, e-mail:
> > log4j-user-help@jakarta.apache.org
> >
> >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Free Pop-Up Blocker - Get it now
> > http://companion.yahoo.com/
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
> 
> 
> begin 600 log4j.xml
> M/#]X;6P@=F5R<VEO;CTB,2XP(B!E;F-O9&EN9STB551&+3@B/SX-"CPA1$]#
> M5%E012!L;V<T:CIC;VYF:6=U<F%T:6]N(%-94U1%32`B;&]G-&HN9'1D(CX-
> M"CQL;V<T:CIC;VYF:6=U<F%T:6]N('AM;&YS.FQO9S1J/2)H='1P.B\O:F%K
> M87)T82YA<&%C:&4N;W)G+VQO9S1J+R(@9&5B=6<](F9A;'-E(CX-"@T*("`\
> M87!P96YD97(@;F%M93TB1DE,12(@8VQA<W,](F]R9RYJ8F]S<RYL;V=G:6YG
> M+F%P<&5N9&5R+D1A:6QY4F]L;&EN9T9I;&5!<'!E;F1E<B(^#0H@("`@/'!A
> M<F%M(&YA;64](E1H<F5S:&]L9"(@=F%L=64](D524D]2(B\^#0H@("`@/'!A
> M<F%M(&YA;64](D9I;&4B('9A;'5E/2(D>VIB;W-S+G-E<G9E<BYH;VUE+F1I
> M<GTO;&]G+W-E<G9E<BYL;V<B+SX-"B`@("`\<&%R86T@;F%M93TB07!P96YD
> M(B!V86QU93TB=')U92(O/@T*("`@(#QP87)A;2!N86UE/2)$871E4&%T=&5R
> M;B(@=F%L=64](B<N)WEY>7DM34TM9&0B+SX-"B`@("`\;&%Y;W5T(&-L87-S
> M/2)O<F<N87!A8VAE+FQO9S1J+E!A='1E<FY,87EO=70B/@T*("`@("`@/'!A
> M<F%M(&YA;64](D-O;G9E<G-I;VY0871T97)N(B!V86QU93TB)60@)2TU<"!;
> M)6-=("5M)6XB+SX-"B`@("`\+VQA>6]U=#X)("`@(`T*("`\+V%P<&5N9&5R
> M/@T*("`)#0H@("`@/&%P<&5N9&5R(&YA;64](DI$0D,B(&-L87-S/2)C;VTN
> M='5M8FQE=V5E9"YM97-S96YG97(N;&]G9VEN9RY-97-S96YG97)*1$)#07!P
> M96YD97(B/@T*("`@(#QP87)A;2!N86UE/2)4:')E<VAO;&0B('9A;'5E/2)%
> M4E)/4B(O/@T*("`@(#QP87)A;2!N86UE/2)S<6PB(`T*("`@("`@("!V86QU
> M93TB:6YS97)T(&EN=&\@979E;G1,;V=%=F5N=',@*`T*("`@("`@("`@("`@
> M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("!E=F5N=%1Y<&4L"0D)
> M"0D)"0D)"0T*("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
> M("`@("`@("!E=F5N=$UA8VAI;F4L#0H@("`@("`@("`@("`@("`@("`@("`@
> M("`@("`@("`@("`@("`@("`@("`@(&5V96YT5&EM92P@#0H@("`@("`@("`@
> M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@(&5V96YT240L(`T*
> M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("!E
> M=F5N=$QE=F5L+`D-"B`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
> M("`@("`@("`@("`@979E;G1#871E9V]R>2P-"B`@("`@("`@("`@("`@("`@
> M("`@("`@("`@("`@("`@("`@("`@("`@("`@8V]M<&]N96YT3F%M92P-"B`@
> M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@979E
> M;G1#;&%S<TE$+`T*("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
> M("`@("`@("`@("!E=F5N=$-L87-S1&5S8W)I<'1I;VXL(`T*("`@("`@("`@
> M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("!E=F5N=$1E=&%I
> M;',-"B`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
> M("`I#0H@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("!V86QU
> M97,@*"`-"B`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
> M("`@("`@)7`L(`T*("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
> M("`@("`@("`@("`C5$]+14Y?159%3E1?34%#2$E.15].04U%(RP@#0H@("`@
> M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@(",E9'M-
> M32]D9"]Y>7EY($A(.FUM.G-S?2,L(`T*("`@("`@("`@("`@("`@("`@("`@
> M("`@("`@("`@("`@("`@("`@("`@("`C)6,C+"`-"B`@("`@("`@("`@("`@
> M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@,RP@#0H@("`@("`@("`@
> M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@(#DL#0H@("`@("`@
> M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("-396-U<F4@
> M365S<V%G92!2961I<F5C=",L#0H@("`@("`@("`@("`@("`@("`@("`@("`@
> M("`@("`@("`@("`@("`@("`@(#$V,#`P+`T*("`@("`@("`@("`@("`@("`@
> M("`@("`@("`@("`@("`@("`@("`@("`@("`C6R5C72,L#0H@("`@("`@("`@
> M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("-;)6-[,7U=("4N
> M,S`P;2,-"B`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
> M("`@("`@*0T*"0D-"B`@("`B+SX-"B`@/"]A<'!E;F1E<CX-"@T*("`@/"$M
> M+2`]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T@+2T^#0H@("`\(2TM
> M($%P<&5N9"!M97-S86=E<R!T;R!T:&4@8V]N<V]L92`M+3X-"B`@(#PA+2T@
> M/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]("TM/@T*#0H@("`\87!P
> M96YD97(@;F%M93TB0T].4T],12(@8VQA<W,](F]R9RYA<&%C:&4N;&]G-&HN
> M0V]N<V]L94%P<&5N9&5R(CX-"B`@("`@(#QE<G)O<DAA;F1L97(@8VQA<W,]
> M(F]R9RYJ8F]S<RYL;V=G:6YG+G5T:6PN3VYL>4]N8V5%<G)O<DAA;F1L97(B
> M+SX-"B`@("`@(#QP87)A;2!N86UE/2)487)G970B('9A;'5E/2)3>7-T96TN
> M;W5T(B\^#0H@("`@("`\<&%R86T@;F%M93TB5&AR97-H;VQD(B!V86QU93TB
> M24Y&3R(O/@T*#0H@("`@("`\;&%Y;W5T(&-L87-S/2)O<F<N87!A8VAE+FQO
> M9S1J+E!A='1E<FY,87EO=70B/@T*("`@("`@("`@/"$M+2!4:&4@9&5F875L
> M="!P871T97)N.B!$871E(%!R:6]R:71Y(%M#871E9V]R>5T@365S<V%G95QN
> M("TM/@T*("`@("`@("`@/'!A<F%M(&YA;64](D-O;G9E<G-I;VY0871T97)N
> M(B!V86QU93TB)61[04)33TQ55$5]("4M-7`@6R5C>S%]72`E;25N(B\^#0H@
> M("`@("`\+VQA>6]U=#X-"B`@(#PO87!P96YD97(^#0H-"B`@/&%P<&5N9&5R
> M(&YA;64](DY4179E;G1,;V<B(&-L87-S/2)O<F<N87!A8VAE+FQO9S1J+FYT
> M+DY4179E;G1,;V=!<'!E;F1E<B(^#0H@("`@(#QP87)A;2!N86UE/2)4:')E
> M<VAO;&0B('9A;'5E/2)%4E)/4B(O/@T*("`@("`\;&%Y;W5T(&-L87-S/2)O
> M<F<N87!A8VAE+FQO9S1J+E!A='1E<FY,87EO=70B/@T*("`@("`@("`\<&%R
> M86T@;F%M93TB0V]N=F5R<VEO;E!A='1E<FXB('9A;'5E/2(E9"`E+35P(%LE
> M=%T@)6,@*"5&.B5,*2`M("5M(B\^#0H@("`@(#PO;&%Y;W5T/@T*("`\+V%P
> M<&5N9&5R/@T*#0H@(#QC871E9V]R>2!N86UE/2)C;VTN='5M8FQE=V5E9"(^
> M#0H@("`@/&QE=F5L('9A;'5E/2))3D9/(B\^#0H@(#PO8V%T96=O<GD^#0H@
> M(`T*("`\8V%T96=O<GD@;F%M93TB8V]M+G1U;6)L97=E960N;65S<V5N9V5R
> M+FQO9V=I;F<B/@T*("`@(#QL979E;"!V86QU93TB24Y&3R(O/@T*("`@(#QA
> M<'!E;F1E<BUR968@<F5F/2)#3TY33TQ%(B\^#0H@("`@/&%P<&5N9&5R+7)E
> M9B!R968](D9)3$4B+SX-"B`@("`\87!P96YD97(M<F5F(')E9CTB3E1%=F5N
> M=$QO9R(O/@T*("`\+V-A=&5G;W)Y/@T*#0H@(#QR;V]T/@T*("`@(#QA<'!E
> M;F1E<BUR968@<F5F/2)#3TY33TQ%(B\^#0H@("`@/&%P<&5N9&5R+7)E9B!R
> M968](D9)3$4B+SX-"B`@("`\87!P96YD97(M<F5F(')E9CTB2D1"0R(O/@T*
> M("`@(#QA<'!E;F1E<BUR968@<F5F/2).5$5V96YT3&]G(B\^#0H@(#PO<F]O
> @=#X-"B`@#0H\+VQO9S1J.F-O;F9I9W5R871I;VX^#0H=
> `
> end


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Mime
View raw message