
OK, I feel ridiculous; and I really thought I did this before with Logback/slf4j. Please give me a LMFGTFY, and I will happily take it! ;-) I have googled, reviews the docs, etc. The problem is, when logging an array, only the first element shows. Is this WAD - is there a config to get it to do all? Do I have to loop it myself and log each item?

Jeff Jensen skrev:
OK, I feel ridiculous; and I really thought I did this before with Logback/slf4j. Please give me a LMFGTFY, and I will happily take it! ;-) I have googled, reviews the docs, etc. The problem is, when logging an array, only the first element shows. Is this WAD - is there a config to get it to do all? Do I have to loop it myself and log each item?
Might you be hitting into a varargs interpretation? What happens if you add more {}'s to your logging string? If that is the case you might trick the compiler by putting your array in a "new Object[1]". -- Thorbjørn Ravn Andersen "...plus... Tubular Bells!"

Not sure about that... To share the issue, I just created a small test case that exhibits the behavior; the files are attached. Just run the test class - you will see an int[] works fine, but a Type[] obtained from reflection does not. I'm stumped... Needs a debug session into logback code which I'm pressed to do ATM. -----Original Message----- From: logback-user-bounces@qos.ch [mailto:logback-user-bounces@qos.ch] On Behalf Of Thorbjoern Ravn Andersen Sent: Monday, November 02, 2009 3:21 PM To: logback users list Subject: Re: [logback-user] logging arrays? Jeff Jensen skrev:
OK, I feel ridiculous; and I really thought I did this before with Logback/slf4j. Please give me a LMFGTFY, and I will happily take it! ;-) I have googled, reviews the docs, etc. The problem is, when logging an array, only the first element shows. Is this WAD - is there a config to get it to do all? Do I have to loop it myself and log each item?
Might you be hitting into a varargs interpretation? What happens if you add more {}'s to your logging string? If that is the case you might trick the compiler by putting your array in a "new Object[1]". -- Thorbjørn Ravn Andersen "...plus... Tubular Bells!" _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://qos.ch/mailman/listinfo/logback-user

Jeff Jensen skrev:
Not sure about that... To share the issue, I just created a small test case that exhibits the behavior; the files are attached.
Just run the test class - you will see an int[] works fine, but a Type[] obtained from reflection does not.
I'm stumped... Needs a debug session into logback code which I'm pressed to do ATM.
I can reproduce your description. 23:48:28.486 [main] DEBUG logback.LogArrayTest - the array=[1, 2, 3, 4, 5, 6, 7, 8] 23:48:28.559 [main] DEBUG logback.ParameterizedTypeTestClass - genericSuperClass=logback.ParameterizedTypeTestClass<java.lang.Long, java.lang.Object> 23:48:28.559 [main] DEBUG logback.ParameterizedTypeTestClass - ActualTypeArguments=class java.lang.Long 23:48:28.560 [main] DEBUG logback.ParameterizedTypeTestClass - ActualTypeArguments array count=2 23:48:28.560 [main] DEBUG logback.ParameterizedTypeTestClass - type=class java.lang.Long 23:48:28.560 [main] DEBUG logback.ParameterizedTypeTestClass - type=class java.lang.Object The tricky code is: Type[] types = genericSuperClass.getActualTypeArguments(); LOG.debug("ActualTypeArguments={}", types); // only displays the first element: // ActualTypeArguments=class java.lang.Long LOG.debug("ActualTypeArguments array count={}", types.length); for (Type type : types) { LOG.debug("type={}", type); } This is with slf4j 1.5.8 and logback 0.9.15 -- Thorbjørn Ravn Andersen "...plus... Tubular Bells!"

Thanks for trying and verifying! And I'm using the same slf4j, but 0.9.17 logback. I entered a defect item to start with... http://jira.qos.ch/browse/LBGENERAL-36 -----Original Message----- From: logback-user-bounces@qos.ch [mailto:logback-user-bounces@qos.ch] On Behalf Of Thorbjoern Ravn Andersen Sent: Monday, November 02, 2009 4:56 PM To: logback users list Subject: Re: [logback-user] logging arrays? Jeff Jensen skrev:
Not sure about that... To share the issue, I just created a small test case that exhibits the behavior; the files are attached.
Just run the test class - you will see an int[] works fine, but a Type[] obtained from reflection does not.
I'm stumped... Needs a debug session into logback code which I'm pressed to do ATM.
I can reproduce your description. 23:48:28.486 [main] DEBUG logback.LogArrayTest - the array=[1, 2, 3, 4, 5, 6, 7, 8] 23:48:28.559 [main] DEBUG logback.ParameterizedTypeTestClass - genericSuperClass=logback.ParameterizedTypeTestClass<java.lang.Long, java.lang.Object> 23:48:28.559 [main] DEBUG logback.ParameterizedTypeTestClass - ActualTypeArguments=class java.lang.Long 23:48:28.560 [main] DEBUG logback.ParameterizedTypeTestClass - ActualTypeArguments array count=2 23:48:28.560 [main] DEBUG logback.ParameterizedTypeTestClass - type=class java.lang.Long 23:48:28.560 [main] DEBUG logback.ParameterizedTypeTestClass - type=class java.lang.Object The tricky code is: Type[] types = genericSuperClass.getActualTypeArguments(); LOG.debug("ActualTypeArguments={}", types); // only displays the first element: // ActualTypeArguments=class java.lang.Long LOG.debug("ActualTypeArguments array count={}", types.length); for (Type type : types) { LOG.debug("type={}", type); } This is with slf4j 1.5.8 and logback 0.9.15 -- Thorbjørn Ravn Andersen "...plus... Tubular Bells!" _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://qos.ch/mailman/listinfo/logback-user
participants (2)
-
Jeff Jensen
-
Thorbjoern Ravn Andersen