Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a log4net memory appender?

Tags:

log4net

I'm looking for a way for a command line program to be able to email its log4net output to a group of users. Right now, I'm reading the log file but I have to call log4net.LogManager.Shutdown() to release the file so I can read it, and I have to either hard code the log file name or parse the log4net configuration for it. I'd like to be able to configure an additional appender that logs to an in memory location that I can then read from.

I don't mind creating a new appender for this functionality, but I'm not sure what the best option is. I certainly don't want to rely on another file, database, or external data source just to get my log output.

like image 763
Chris Avatar asked Oct 29 '10 16:10

Chris


People also ask

What is Appender ref in log4net?

<root> <level value="INFO" /> <appender-ref ref="ConsoleAppender" /> </root> </log4net>

Is log4net based on log4j?

The Apache log4net library is a tool to help the programmer output log statements to a variety of output targets. log4net is a port of the excellent Apache log4j™ framework to the Microsoft® . NET runtime.

What are the main components of log4net?

Log4net has three main components: loggers, appenders and layouts. These three types of components work together to enable developers to log messages according to message type and level, and to control at runtime how these messages are formatted and where they are reported.

Where is log4net configuration file?

You can configure the log4net. config file to create log files. The file is located in the webroot\App_data directory of the installation.


2 Answers

Wouldn't the SmtpAppender be more appropriate for this use? It emails directly.

like image 20
Ross Patterson Avatar answered Oct 05 '22 12:10

Ross Patterson


Yes, there is log4net.Appender.MemoryAppender. It has a GetEvents() method that you can use to obtain the events that have been logged.

like image 96
Mark Rushakoff Avatar answered Oct 05 '22 13:10

Mark Rushakoff