Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Mini Drop-in Replacement for log4net

, 5 May 2012 CPOL
Mini drop-in replacement for log4net
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using log4net;

namespace mylogger
    public partial class Form1 : Form
        public Form1()

        ILog _log = LogManager.GetLogger(typeof(Form1));

        private void Form1_Load(object sender, EventArgs e)
            LogManager.Configure("logs\\log.txt", 1000, false);
            _log.Error("hello", new Exception("asdasd"));

        private void button1_Click(object sender, EventArgs e)
            Random r = new Random();
            for (int i = 0; i < 100; i++)
                _log.Info("hello " + i + " " + r.Next(100000));

        private void timer1_Tick(object sender, EventArgs e)
            if (progressBar1.Value < progressBar1.Maximum)
                progressBar1.Value = 0;

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Mehdi Gholam
United Kingdom United Kingdom
Mehdi first started programming when he was 8 on BBC+128k machine in 6512 processor language, after various hardware and software changes he eventually came across .net and c# which he has been using since v1.0.
He is formally educated as a system analyst Industrial engineer, but his programming passion continues.
* Mehdi is the 5th person to get 6 out of 7 Platinums on CodeProject (13th Jan'12)

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150327.1 | Last Updated 5 May 2012
Article Copyright 2010 by Mehdi Gholam
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid