Yes I'm very interested in this topic.

 If I understand Gary correctly, he needs a way for the application to pass 
byte arrays to the logger, and output these byte arrays as text in hexadecimal 
format. 

https://issues.apache.org/jira/plugins/servlet/mobile#issue/LOG4J2-506 contains 
some work in progress in this area. For Gary, perhaps only the BinaryMessage 
interface is of interest. This can then be combined with a HexDumpLayout to 
format to byte array as text. I was going to use a BinaryLayout to log the byte 
array   directly without converting it to text. So it's important to separate 
input (Message) from output (Layout) here. 

Sent from my iPhone

> On 2014/09/03, at 8:59, Matt Sicker <[email protected]> wrote:
> 
> Wouldn't a Layout make more sense for the output format? And a byte buffer 
> message would be nice. We can support byte[] by using ByteBuffer.wrap() and 
> keeping things consistent. This could also work well with Remko's ideas for 
> garbage-free binary logging. I'd like to hear what he was thinking about in 
> regards to that.
> 
> 
>> On 2 September 2014 12:10, Ralph Goers <[email protected]> wrote:
>> The “best way”?  That depends on what you want.  
>> 
>> If you only want some messages hex dumped and want that controlled in the 
>> application then use the HexDumpMessage.  If you want all of them then do a 
>> HexDumpLayout.  If you want to control this at runtime we might want to add 
>> the ability to choose a Layout based on a Filter.
>> 
>> Ralph
>> 
>>> On Sep 2, 2014, at 9:29 AM, Gary Gregory <[email protected]> wrote:
>>> 
>>> Ah, yes, but then, ALL byte arrays and ByteBuffers will be hex-dumped, 
>>> which should be OK.
>>> 
>>> Well, this is what I am looking for, what is the best log4j2-way to do this.
>>> 
>>> Gary
>>> 
>>> 
>>>> On Tue, Sep 2, 2014 at 12:25 PM, Ralph Goers <[email protected]> 
>>>> wrote:
>>>> Note that you should also be able to do this with a Layout.
>>>> 
>>>> Ralph
>>>> 
>>>>> On Sep 2, 2014, at 9:17 AM, Gary Gregory <[email protected]> wrote:
>>>>> 
>>>>>> On Tue, Sep 2, 2014 at 12:10 PM, Ralph Goers 
>>>>>> <[email protected]> wrote:
>>>>>> So the output from a ByteBufferMessage is a hex dump of the data?  
>>>>> 
>>>>> Yes, with formatting options. Whether we pin it to hexadecimal or allow a 
>>>>> base to be configured is TBD. I only need hex ATM.
>>>>> 
>>>>>> Wouldn’t it make more sense to have a HexDumpMessage that accepts a byte 
>>>>>> buffer or byte array or a string or whatever?
>>>>> 
>>>>> That's where I am going yes, perhaps my proposed class name was 
>>>>> confusing. ByteDumpMessage would be a more general version of 
>>>>> HexDumpMessage.
>>>>> 
>>>>> Gary
>>>>> 
>>>>>> 
>>>>>> Ralph
>>>>>> 
>>>>>>> On Sep 2, 2014, at 8:23 AM, Gary Gregory <[email protected]> wrote:
>>>>>>> 
>>>>>>> Hi All:
>>>>>>> 
>>>>>>> On every project I've worked on, at some point, I or someone needs to 
>>>>>>> log of byte buffer (usually a byte[] but I am working a new project 
>>>>>>> that uses an NIO ByteBuffer too).
>>>>>>> 
>>>>>>> We do not have a Log4j ByteBufferMessage, how about adding one? That 
>>>>>>> seems quite withing the scope of Log4j
>>>>>>> 
>>>>>>> I would expect the following to be parameters:
>>>>>>> 
>>>>>>> - group size in bytes (default 8)
>>>>>>> - group count per line (default 4)
>>>>>>> - uppercase vs. lowercase output (default?)
>>>>>>> - base (default 16, should this even be configurable?)
>>>>>>> - group separator (default space " ")
>>>>>>> - char encoding (default UTF-8 or ASCII), if present extends the a line 
>>>>>>> with text version of the bytes
>>>>>>> - groups-text separator (default " | ")
>>>>>>> - address-groups separator (default " | ")
>>>>>>> - unprintable char (default .)
>>>>>>> 
>>>>>>> 
>>>>>>> Example output line (bogus values):
>>>>>>> 00000 | 01234567 a1234567 b1234567 c1234567 | .HELLO...
>>>>>>> 
>>>>>>> Thoughts?
>>>>>>> 
>>>>>>> Gary
>>>>>>> 
>>>>>>> -- 
>>>>>>> E-Mail: [email protected] | [email protected] 
>>>>>>> Java Persistence with Hibernate, Second Edition
>>>>>>> JUnit in Action, Second Edition
>>>>>>> Spring Batch in Action
>>>>>>> Blog: http://garygregory.wordpress.com 
>>>>>>> Home: http://garygregory.com/
>>>>>>> Tweet! http://twitter.com/GaryGregory
>>>>> 
>>>>> 
>>>>> 
>>>>> -- 
>>>>> E-Mail: [email protected] | [email protected] 
>>>>> Java Persistence with Hibernate, Second Edition
>>>>> JUnit in Action, Second Edition
>>>>> Spring Batch in Action
>>>>> Blog: http://garygregory.wordpress.com 
>>>>> Home: http://garygregory.com/
>>>>> Tweet! http://twitter.com/GaryGregory
>>> 
>>> 
>>> 
>>> -- 
>>> E-Mail: [email protected] | [email protected] 
>>> Java Persistence with Hibernate, Second Edition
>>> JUnit in Action, Second Edition
>>> Spring Batch in Action
>>> Blog: http://garygregory.wordpress.com 
>>> Home: http://garygregory.com/
>>> Tweet! http://twitter.com/GaryGregory
> 
> 
> 
> -- 
> Matt Sicker <[email protected]>

Reply via email to