Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to provide your own timestamp for log4net

I'm trying to provide a Logger using a queue system and Timer to to reduce logging time on my main thread. However I would like to capture the time in which a log message was created instead of when the log message was written. While I could add the timestamp to the message, I would like the option to provide the timestamp to log4net so that I can use the pattern provider to format the written log message.

If providing the timestamp value is not possible. A way to easily format the message pattern before logging would be great.

For example:

<param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" />

--> 2011-12-17 00:00:38,511 [TestRunnerThread] DEBUG GlobalLogger 12:00:38.411400 - Line 1

like image 508
galford13x Avatar asked Dec 01 '25 10:12

galford13x


1 Answers

This might be a little late now, but there is code for a sample asynchronous appender here

like image 103
Matt Craig Avatar answered Dec 03 '25 08:12

Matt Craig



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!