How do you write a byte [] array using log4.net

I have a byte [] with some data in it, I would like to write this AS-IS byte array to a log file using log4.net. The problems I am facing is that

There is no overload for the [] byte in the TextWriter , so even the IObjectRenderer implementation is useless. I don't have access to the underlying Stream Log4.net object Also tried converting byte [] to char [] yet when I write it it adds extra byte.

Is this possible with Log4.net.

Thanx in Advance.

+2


a source to share


4 answers


Log files are usually text files. It is probably best to register your byte array as a string.



Have a look at BitConverter.ToString or Convert.ToBase64String .

+4


a source


Nope. Did you think of writing it as the sixth line (see this post )?



+3


a source


I also find that writing any larger data is useless, however, I think this is what you are looking for - this will convert your bytes to a string.

 System.Text.Encoding.ASCII.GetString(byteArray)

      

I believe you can figure out how to use this for logging.

Pz, developer of TaskConnect

0


a source


If you are logging into the DB, use a binary type with the maximum size

0


a source







All Articles