![]() |
Platforms, Frameworks & Libraries »
.NET Framework »
Utilities
Beginner
License: The Code Project Open License (CPOL)
.NET File Logging LibraryBy msvcycA simple yet useful library for file based logging implemented in .NET using C# |
C#, Windows, .NET, Win32, Win64, Visual Studio, Architect, Dev, Design
|
||||||||||
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
This is a simple yet useful file based logging library along with a sample client application demonstrating the usage of the library.
Following are some of the features of this library.
This library is more like a starter kit with all the base functions in place. Please feel free to customize it for your needs.
Library usage is very simple. The object has to be initialized first using the Initialize method. This is where the log file name and location has to be specified. Optionally, the maximum log file size can be specified as well. The default maximum log file size is 20 MB. Log file will truncate automatically when the configured maximum size is reached.
CLogger TestLogger = new CLogger(); TestLogger.Initialize("C:", "Test.Log"); // Location and file name // TestLogger.Initialize("C:", "Test.Log", 20); // Optional max log size param in MB
Start logging information right away. Each severity level has 3 overloads.
TestLogger.LogInformation("My First Test Log Message");
TestLogger.LogWarning("My First Test Log Message");
TestLogger.LogError("My First Test Log Message");
TestLogger.LogInformation(1005, "My First Test Log Message");
TestLogger.LogInformation("LogClient", "TestLog", "My First Test Log Message");
Finally, this is how the logged statements look like.
[4/5/2008 1:36:29 AM],[1],[Information],LogClient:TestLog:My First Test Log Message
[4/5/2008 1:36:29 AM],[1],[Warning],LogClient:TestLog:My First Test Log Message
[4/5/2008 1:36:29 AM],[1],[Error],LogClient:TestLog:My First Test Log Message
Each statement has the date time stamp, thread id, severity and the message string.
Terminate the logger library using the Terminate statement.
TestLogger.Terminate();
Happy logging. As always, happy to hear any suggestions and criticisms.
Library Version 1.0 - April 05, 2008
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 17 Apr 2008 Editor: |
Copyright 2008 by msvcyc Everything else Copyright © CodeProject, 1999-2009 Web19 | Advertise on the Code Project |