The motivation to write the CherryLog4Net is to log information into a database so that we can easily retrieve the information from the log database using SQL. CherryLog4Net was designed to log information into databases that have their OLE DB Data prividers, and to support log buffering, aging and log level (severity) as well.
Although it was designed to support all databases that have their OLE DB Data providers, CherryLog4Net is preferably to log information into lightweighted embedded databases such as SQLite so that it will not rely on network connectivity.
The source code for CherryLog4Net is free of distribution. You may use it for commercial purposes. You may modify the source code provided you keep the license agreement intact in the source code.
CherryLog4Net was intended to be used in .NET 2.0 applications. CherryLog4Net class library exposes class CherryLog that implemented IDisposable. The CherryLog class has Add and Flush methods.
Add method allows you to add a log entry and save all log entries into a database if the buffer is full. Flush allows you explicitly save all log entries in the buffer before the buffer is full.
Download the C# sample code
Normally, most of you could use CherryLog4Net library 'AS IS'. Some of you may want to customize it to accommodate your specific logging cases.
For example, you may have a web application that allow users to log on it. You may want to log error, warning, or information on user bases to figure out what might cause problems. In this case, you want to add a user column when you CreateTable() in class CherryLogTable. In the CherryLog class, you want to modify the Save and Add method to make log the user information. Of cause, you may create your derived classes instead of modifying the existing classes.
The current CherryLog4Net implementation utilize SQLite embedded database to store log information. You can use SQlite3.exe command line tool to retrieve log information.
The screenshot below demostrates how we retrieve log information. The first query retrieves all log information. The second query retrieve only error log information. Image, if we have millions of records, it will be a lot easier to write a query to get needed information out of a database than to find a needle in a hay if we log information into a huge file.
Using SQLite DB provider with Visual Studio 2005, we can also readily retrieve log entries