Click here to Skip to main content
Licence 
First Posted 18 Aug 2002
Views 55,231
Bookmarked 24 times

Yet another Logger class

By | 18 Aug 2002 | Article
The Logger class helps .NET developer create application logs in an easy way.

Introduction

This is a simple Log component that will help you to create Logs for your application. It is very simple and easy to use.

Code

The public static string GetNewLogFilename() creates a log filrname if DD-MM-YYYY.LOG format. You also have a LogType enum to specify the log entry types

public enum LogType
{	 
	Info = 1,
	Warning = 2,
	Error = 3
}

How use use

....
// GetNewLogFilename() is static member and dosn't need to be
// instantiated. Returns like 19-08-2002.log
string strMyLogFile = Logger.GetNewLogFilename()   
                                                   
Logger objLog = new Logger( strMyLogFile );
....
objLog.WriteLine(LogType.Info,"Application started.");
....
objLog.WriteLine(LogType.Warning,
                 "Application is going to fail here... be alert...");
....
objLog.WriteLine(LogType.Error,"The Application has died just now :(");
....
objLog.WriteLine(LogType.Info,"Terminating Application");

Have fun C#ing.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Gevik Babakhani

Web Developer

Netherlands Netherlands

Member



Organisation (No members)

Gevik Babakhani is a software architect currently residing in The Netherlands. He started programming as hobby from the age of 12. His professional career began in 1997. Since then he works fulltime as a software architect. Currently he dedicates time and effort in Microsoft.NET.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralDateTime format is off PinmemberMark F Garrison7:39 10 Mar '03  
Generallog4net, a better solution PinmemberRoelof Blom4:45 27 Aug '02  
GeneralRe: log4net, a better solution PinsussAnonymous10:55 27 Aug '02  
This is an example not a total solution!
GeneralRe: log4net, a better solution PinmemberStoney Tian23:00 17 Nov '02  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120604.1 | Last Updated 19 Aug 2002
Article Copyright 2002 by Gevik Babakhani
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid