Monthly Archives: October 2004

System.XML reference

27 Oct 2004
by mjeaton, posted in Uncategorized   |  Comments Off

As I’m trying to catch up on my blog reading, I just ran across a post from Roy Osherove: “TopXML releases the System.XML reference online”.


I wish I would have read this post a few days ago, because I was struggling with some Xml code…anyway, this is a great site.

Incompetent management

27 Oct 2004
by mjeaton, posted in Uncategorized   |  Comments Off

From Joe White’s blog – “Beatings will continue until morale improves


I love this exchange:
O: You guys have been missing the deadlines that I’ve set. You need to start working 60-hour weeks.
B: Deadlines are a symptom, not the problem. Are we going to get real product managers? Are we going to fix the other problems in our processes?
O: Shut up, B.


This is a good reason for going indepedent. :-)


I’d like to know how much input the developers had into the deadlines they’ve been missing.

Learning SharePoint

26 Oct 2004
by mjeaton, posted in Uncategorized   |  Comments Off

I found this

Very cool T-SQL code

26 Oct 2004
by mjeaton, posted in Uncategorized   |  Comments Off

From Ryan FarleyT-SQL Olympics


That is very cool stuff.

Requirements Analysis is like…

26 Oct 2004
by mjeaton, posted in Uncategorized   |  Comments Off

this.

Blog spam sucks

26 Oct 2004
by mjeaton, posted in Uncategorized   |  Comments Off

Got hit today with my first blog spam. :-\

The upcoming election

24 Oct 2004
by mjeaton, posted in Uncategorized   |  Comments Off


Will everyone else on the planet shut the fuck up about our election?

A great FTP component

23 Oct 2004
by mjeaton, posted in Uncategorized   |  Comments Off

Please note: I am in no way, shape or form affiliated with Aberaware.

Using the log4net AdoNetAppender

23 Oct 2004
by mjeaton, posted in Uncategorized   |  6 Comments

In my ‘Getting Started with log4net‘ post, I described how I was able to quickly and easily get log4net working using the FileAppender and the ConsoleAppender.


I’m actually using the AdoNetAppender in some applications I’m currently working on (I’m actually using the RollingFileAppender, ConsoleAppender and the AdoNetAppender, but more on that later).


The sample for using the AdoNetAppender given in the log4net docs

Getting started with log4net

21 Oct 2004
by mjeaton, posted in Uncategorized   |  11 Comments

Update (11/9/2004 @ 1:50PM EST): Here is a zip file containing a VS.NET solution for this post.

After using this logging solution for the last few months, I finally decided it was time to figure out log4net.

The funny thing is that my initial experience was very similar to this.

The first step (after installing log4net of course) was to get the simplest code running:

// add a reference to the log4net assembly
using System;
using log4net;
using log4net.Config;
public class logTest {
    private static readonly ILog _logger = LogManager.GetLogger(typeof(logTest));
    public static void Main(string[] args) {
        log4net.Config.BaseConfigurator.Configure();
        _logger.Debug("This is a debug message");
    }
}

Compile and run. By default, all logs are dumped to the console (that’s what the BaseConfigurator.Configure() method is for).

The logs look like:
0 [4720] DEBUG logTest  – This is a debug message

log4net has what are called “Appenders”. You can think of these as log message destinations. The default is ConsoleAppender, but log4net ships with about a dozen, including SmtpAppender, FileAppender, AdoNetAppender and many more.

The quickest and easiest way to start using the Appenders is to modify your app.config file.

Adding new appenders is as simple as modifying the config file.  If I want the logs to be written to a database, I would add an AdoNetAppender (prereqs: add the table first).  You can also change the layout of the logs by modifying your config file as well.  In the config file I used for my sample, note this line:

This format is:
date level logger message (and %n is a line-break)

I actually had to dig into the code to find out all the values for the ‘PatternLayout’.  You can specify things like class name, method name, line number and thread.  Very cool stuff.

The code will need to be modified just a bit:

// add a reference to the log4net assembly
using System;
using log4net;
using log4net.Config;

[assembly: log4net.Config.DOMConfigurator(Watch=true)]
public class logTest {
    private static readonly ILog _logger = LogManager.GetLogger(typeof(logTest));
    public static void Main(string[] args) {
        _logger.Debug("This is a debug message");
    }
}

Notice the attribute on the assembly? That tells log4net to find its configuration information in the applications app.config file.

Compile and run and you should see a file named ‘mylog.txt’ in the same directory as the executable file.

More on my log4net experiences in another post.