PatternLayout defaults to implicitly add %ex or one of its variations to your pattern if you don’t specify it. To disable exception logging you have to use %noex.
Ralph > On Sep 22, 2016, at 6:55 AM, Matt Sicker <boa...@gmail.com> wrote: > > I usually don't even include %exception in my pattern layouts for some > reason, probably because of the double logging. So I'd go with (1) as well. > > On 22 September 2016 at 02:59, Gary Gregory <garydgreg...@gmail.com > <mailto:garydgreg...@gmail.com>> wrote: > Hi All, > > The method > org.apache.logging.log4j.web.appender.ServletAppender.append(LogEvent) is > defined as: > > @Override > public void append(final LogEvent event) { > servletContext.log(((AbstractStringLayout) > getLayout()).toSerializable(event)); > } > > Instead of: > > @Override > public void append(final LogEvent event) { > servletContext.log(((AbstractStringLayout) > getLayout()).toSerializable(event), event.getThrown()); > } > > Which does not give the best information we have to the servlet context > logging. > > The tricky part is that to avoid logging the exception twice like in our test > org.apache.logging.log4j.web.ServletAppenderTest. To avoid the double > logging, we could (1) document not using a %exception in the pattern layout. > > That or (yikes) (2) provide a variation of the toSerializable(event) like > toSerializable(event, false), where the boolean is an ignoreException > parameter. It seems there are plenty of places where exceptions are treated > specially already, this would be another. > > I like (1) better because it is simpler. > > Thoughts? > > Thank you, > Gary > > > -- > E-Mail: garydgreg...@gmail.com <mailto:garydgreg...@gmail.com> | > ggreg...@apache.org <mailto:ggreg...@apache.org> > Java Persistence with Hibernate, Second Edition > <http://www.manning.com/bauer3/> > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> > Spring Batch in Action <http://www.manning.com/templier/> > Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> > Home: http://garygregory.com/ <http://garygregory.com/> > Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory> > > > -- > Matt Sicker <boa...@gmail.com <mailto:boa...@gmail.com>>