logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <ralph.go...@dslextreme.com>
Subject Re: Multiple Markers vs. Marker multiple inheritance.
Date Wed, 02 Mar 2016 00:29:34 GMT
I don’t see the point of accepting an array of Markers since you can always create a Marker
that has multiple parents - effectively making it an array of Markers.  However, this relationship
is meant to be permanent - which makes sense to me since you should only be using a Marker
to mean a single thing in an application.

What I don’t really understand is how one FooException is “softer” than another FooException.
 I do understand how throwing a Type1Exception might be more significant than a Type2Exception,
but that might be better expressed in the Exception hierarchy than in Markers. 

I could certainly see creating an ExceptionPatternSelector that uses a PatternLayout that
only prints the exception message for some exceptions and prints the stack trace for others.

I suppose I could also see creating an ExceptionFilter that filters based on the exception
type.

I guess it just feels wrong to me for a developer to have to add a Marker to an exception
event to somehow add more significance to the event.

Ralph

> On Mar 1, 2016, at 4:24 PM, Gary Gregory <garydgregory@gmail.com> wrote:
> 
> Hi All:
> 
> Is the following an odd-ball use case or a super-niche use case, and should we do anything
about it.
> 
> I have a part of our app that throws and logs an exception with the usual:
> 
> logger.throwing(new FooException(...));
> 
> Elsewhere in this class and in the same method, I have softer errors for which I log
a warning with a a custom marker.
> 
> What I really want is to be able to filter out both log events based on this marker but
not other kinds of events, hence the use of Markers.
> 
> I cannot say:
> 
> logger.throwing(myMarker, new FooException(...)); 
> 
> Our implementation marks throwing() log event (helpfully) with its own THROWING_MARKER.
> 
> I could make my custom marker a child of THROWING_MARKER, but that is really not semantically
correct, is smelly and therefore a nasty hack IMO.
> 
> If I had a logger.throwing(Marker, Throwable); API, how would it work?
> 
> I would say that LogEvent should hold an array of Markers, not a single one.
> 
> What does this sound like to you all? Craziness or a power-user refinement?
> 
> Let's only consider throwing() for now before we even think about adding Logger APIs
that take Marker[]s.
> 
> Gary
> 
> 
> -- 
> E-Mail: garydgregory@gmail.com <mailto:garydgregory@gmail.com> | ggregory@apache.org
 <mailto:ggregory@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>

Mime
View raw message