Sanjay Gupta Sanjay Gupta - 2 months ago 35
C# Question

How to log Byte[] data in log4net using AdoNetAppender

I want to log a gzip-compressed string, which will be in binary

format, in a
SQL table column using log4net's

My questions:

1) Is this possible? If so, what
I need to use as parameter in my config file below:

<parameterName value="@Data" />
<dbType value="String" />
<size value="2147483647" />
<layout type="log4net.Layout.RawPropertyLayout">
<key value="Data" />

2) Are there alternatives other than converting the value to a string and then logging it.


I think the best way to log you binary Byte[] is to convert it to a base64 string. There is no way to pass a Byte[] type as value to log4net logging methods.