Info
Version: | 1.2.0 |
Author(s): | Arkadeep De |
Last Update: | Friday, December 9, 2016 |
.NET Fiddle: | Create the first Fiddle |
Project Url: | https://www.nuget.org/packages/DoLog/ |
NuGet Url: | https://www.nuget.org/packages/DoLog |
Install
Install-Package DoLog
dotnet add package DoLog
paket add DoLog
DoLog Download (Unzip the "nupkg" after downloading)
Dependencies
- SampleDependency(>= 1.0.0)
Tags
Install it through Nuget package and your logging functionality is ready.
Steps to Add DoLog:
1. Run the command from Nuget package manager console.
2. Add the namespace
using DoLogLibrary; // put it in namespace section
3. For windows applications, you don't need to set the log file location path.
For web application write the below code in App_Start method in Global.ascx.
DoLog.SetLogLocation(Server.MapPath("~")); // Set the location of log file for web application
4. For Logging use method Log under DoLog class. This is a static method, so you don't need to create any kind of object.
Examples:
DoLog.Log("Application Starts");
DoLog.Log(ex.Message,"Error");
DoLog.Log("Application Ends", "Info");
"Log" takes two parameters. first one is the message and second one is the level of message(like info, warning, error or anything user puts).
Method returns a tuple<bool, string>
first items state whether logging operation is successful or not, and second item states the location of log file.
In our new version you can also log data in Database.
A database table named TBL_DOLOG will be created and all the log data will be stored over there.
To access this feature use method LogDB() and SetConnectionString().
Example:
// Set the connection string first
DoLog.SetConnectionString(@"Data Source=localhost;Integrated Security=True;Initial Catalog=TestDB;");
// Do the logging operation (return true or false)
DoLog.LogDB("This is a test data.");
DoLog.LogDB(ex.Message,"Error");.