log4net? Not for Me

I’ve just made a decision not to build my logging in any application on log4net.

I’m sure log4net is a wonderful tool that can log anything, anywhere, to any log consumer. But after sitting here struggling for hours in trying to get it to log correctly – both for myself and for a client’s ASP.NET application – I’ve decided against it.

The thing is, it violates the KISS principle. (Keep It Simple, Stupid.)

Anything that you can’t get up and running – and this is supposed to be remarkably simple – within a short amount of time, does not deserve my attention. log4net, to me, is too powerful, too complex, too difficult. There is just too much trouble getting the XML configuration to work correctly, and too much pulling the hairs out when it doesn’t work. My time is far too valuable to spend it trying to get logging to work.

Putting all configuration into an XML file – even how to tie the internal components of a program together – is just downright evil. And it’s not the way to go.

The KISS principle, and its cousin Rock Steady, but shake their heads and move on.

5 thoughts on “log4net? Not for Me

  1. I don’t know about log4net but the original, log4j, is pretty easy to use.

    * Include the jar
    * Reference the configuration on the command line
    * Create a Logger object in your code
    * Use it

    The config kan be written as an XML file or a simple property file:

    # Set root category priority to INFO and its only appender to CONSOLE.
    log4j.rootCategory=INFO, CONSOLE

    # CONSOLE is set to be a ConsoleAppender using a PatternLayout.
    log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
    log4j.appender.CONSOLE.Threshold=INFO
    log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
    log4j.appender.CONSOLE.layout.ConversionPattern=- %m%n

  2. Hmm. Must look into that. Embedding the configuration into the App.config file and getting log4net to read the file is certainly less than fun.

  3. There doesn’t seem to be be any “simple property files” that can be used in log4net. Just XML.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>