Now with .NET Core Support, MLog is a simple .NET Library for Data Logging in your .NET Apps.
//Task: Create a Log for the creation of a New Student
Mlog.Log log = Mlog.Log.Create<Student>(newStudent);
log.Title = "New Student Created: [" + newStudent.FullName + "]";
log.Description = log.Application + " Data Log for " + title;
Mlog.Manager.Add(log);
Logs have parent-children relationships using the Parent
property of each Log-Item. To Create a Child Log:
//Task: Create a Log for the creation of a New Student's Course
var coursesLog = Mlog.Log.Create<List<Course>>(newStudent.GetCourses());
log.Title = "New Courses added for [" + newStudent.FullName + "]";
log.Description = log.Application + " Data Log for " + title;
log.AddChild(coursesLog);
Mlog.Manager.Add(log);
For documentation purposes, you might want to include the IP Address of the User who performs an Action in its Log.
log.IpAddress = MLog.Util.GetIpAddress();
[Route("api/students/add")]
public Response<Student> Add([FromBody()] Models.User val)
{
return MLog.Manager.AddRequestAndResponse<Response<Student>, User>("api-student-add", val, (Student values) =>
{
return new Response<Student>("New Student Created", Student.Add(values), true);
});
}
- Newtonsoft JSON (view)
- MongoDB.Core (view)
- MongoDB.Driver (view)
- Microsoft .NET Framework 4.5.2 (download)
<appSettings>
<add key="mlog-app" value="MlogTests" />
</appSettings>
<connectionStrings>
<add name="MLog.Properties.Settings.MLogConnectionString" connectionString="Data Source=MYKEELS-PC;Initial Catalog=MLog;User ID=[your db username];Password=[your password]"
providerName="System.Data.SqlClient" />
</connectionStrings>
{
"appSettings": {
"mlog-app": "MlogTests",
"MongoDBUri": "mongodb://localhost:27017",
"MongoDBName": "MLogTests"
},
"connectionStrings": [
{
"name": "MLog.Properties.Settings.MLogConnectionString",
"connectionString": "Data Source=MYKEELS-PC;Initial Catalog=MLog;User ID=mykeels",
"providerName": "System.Data.SqlClient"
}
]
}
The dream is to make MLog multi-platform using the .NET Standard, and ensure it is possible to use MLog with the following Databases:
- SQL Server
- MongoDB
Also, we need to provide developer-users with a way to configure MLog using Lamda Expressions, so they can make MLog behave in any number of ways to suit their applications.
Follow me on twitter. Star this github repo . Check out my other projects and see if you like them.
Provide useful code critism. I'd love to hear from you, really.
Thanks! Ikechi Michael I.
The MIT License. Please see License File for more information.