This project is read-only.

Twitter to SQL uses Log4Net for application logging. For users unfamiliar with Log4Net the following quote is taken from their website:

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. We have kept the framework similar in spirit to the original log4j while taking advantage of new features in the .NET runtime. For more information on log4net see the features document.

Out of the box Twitter to SQL will simply send all of the logging messages to the console. All configuration information is stored in the Log4Net.config file. If you desire to send log messages to a more permanent location such as a file or a SQL Server table you should edit this file and provide the appropriate information. Full documentation of the various options can be found on the Log4Net website on the Configuration page. Tim Corey has written an excellent tutorial with examples on Code Project.


Why logging?

Many of you may be wondering why we included provisions for logging in Twitter to SQL rather than leaving it for the user to add for himself. The answer is twofold: For those that don’t care about logging they can simply disable it by deleting the log4Net.config file. For anyone wishing to automate the regular collection of tweets to the database some form of logging a practical necessity. Because Log4Net does all the heavy lifting, very little effort was required to actually implement logging.

Advanced logging to SQL Server

For an example of how to store the logfile in SQL Server see: Logging to SQL Server

Debugging Tip

When the program runs it needs to find its configuration file. If it does not find Log4Net.config the program will still run but you will not get any log output. As described in the FAQ:

Is log4net a reliable logging system?

No. log4net is not reliable. It is a best-effort and fail-stop logging system.

By fail-stop, we mean that log4net will not throw unexpected exceptions at run-time potentially causing your application to crash. If for any reason, log4net throws an uncaught exception (except for ArgumentException and ArgumentNullException which may be thrown), please send an email to the mailing list. Uncaught exceptions are handled as serious bugs requiring immediate attention.

Moreover, log4net will not revert to System.Console.Out or System.Console.Error when its designated output stream is not opened, is not writable or becomes full. This avoids corrupting an otherwise working program by flooding the user's terminal because logging fails. However, log4net will output a single message to System.Console.Error and System.Diagnostics.Trace indicating that logging can not be performed.

If you find you are not getting log output, you should check to make sure that the program can read the Log4Net.config file. Generally you will want the config file to be located in the same directory as the program.

If you are creating a desktop icon or automating the program with Task Scheduler then be sure to set the Start in: parameter and that whatever directory it points to contains the config file.

Last edited Mar 12, 2014 at 10:33 AM by JonnyBoats, version 7