logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David KOCH <dk...@ezakus.com>
Subject Re: Unable to create detached markers via log4j-slf4j-impl 2.1.
Date Wed, 12 Nov 2014 08:06:44 GMT
Hi Ralph,

I worked around the issue. Basically, I had a setup where I had basic
markers A, B and a marker C which existed in 2 versions:
1) C - with reference to A and 2) C with reference to B. What I did instead
was create 2 separate markers. "C_A" with references to C and A and "C_B"
with references to C and B.

Regards,

/David

On 10 November 2014 21:46, Ralph Goers <ralph.goers@dslextreme.com> wrote:

> Yes, that should be documented. Log4j 2 doesn’t currently support detached
> markers.
>
> If you can create a Jira issue for this and why a detached marker is
> required we can consider it.  However, detached markers introduce some
> performance and thread safety issues so we would really need to understand
> the benefit so we can weigh it against the cost.
>
> Ralph
>
> > On Nov 10, 2014, at 9:32 AM, David KOCH <dkoch@ezakus.com> wrote:
> >
> > Hello,
> >
> > I am unable to create detached versions of existing markers when using
> > log4j2 through the slf4j facade - log4j2 version is 2.1.
> >
> > Example:
> >
> > import org.slf4j.Marker;
> > import org.slf4j.MarkerFactory;
> >
> > public class TestMarker {
> >
> >    public static void main(String[] args) {
> >       Marker markerA = MarkerFactory.getMarker("testA");
> >       Marker markerB = MarkerFactory.getMarker("testB");
> >       markerA.add(markerB);
> >       Marker markerANew = MarkerFactory.getDetachedMarker("testA");
> >       // Iteration below will fail if this line is uncommented.
> >       //System.out.println("Removing reference from detached markerA: " +
> > markerANew.remove(markerB));
> >
> >       System.out.println("Has reference marker A: " +
> > markerA.hasReferences());
> >       System.out.println("Has reference detached marker A: " +
> > markerANew.hasReferences());
> >
> >
> >       Iterator<Marker> mRef = markerA.iterator();
> >       while (mRef.hasNext()) {
> >           System.out.println(mRef.next().getName());
> >       }
> >
> >       mRef = markerANew.iterator();
> >       while (mRef.hasNext()) {
> >           System.out.println(mRef.next().getName());
> >       }
> >
> >    }
> >
> > }
> >
> > Actual output:
> >
> > Has reference marker A: true
> > Has reference detached marker A: true
> >
> > Expected output (which I get when using native slf4j logging
> implementation
> > logback):
> >
> > Has reference marker A: true
> > Has reference detached marker A: false
> >
> > I am trying to keep my application log framework agnostic but it seems
> like
> > it's not possible in this case. Since it's currently impossible via
> > log4j-slf4j-impl, is there a "pure" log4j2 way of getting detached marker
> > instances?
> >
> > The feature is quite important to us since marker names and references
> both
> > play important parts in how we route and parse our logs.
> >
> > Thank you,
> >
> > Regards,
> >
> > /David
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message