Simple, extensible activity/event logging implementation for .NET
Extend and register (as a Singleton) via DI the below interface for logging activities.
public interface IActivityLogger
{
void Log(Activity e);
}
Create your custom Activities by inheriting from the below:
public abstract class Activity : IActivity
{
}
Basic properties would include
ActivityLogLevel Level // LogLevel enum
string EntitySubject
string Event
string Description
DateTimeOffset EventTime
Apart from the above, each Activity can hold an optional number of parameters/entities/objects
AddParam(ActivityParam param)
An Activity can be enhanced with Caller Information by using
WithCallerInfo()
An Activity can be also be enhanced with certain context related information, which would be certain common properties, specific to application usage (or) context
ActivityLogger?.Log(new ConcreteActivity
{
Description = $"",
EntitySubject = "",
Event = "",
Level = ActivityLogLevel.Debug,
}
.With(ActivityParam.New(Id, ""))
.With(ActivityParam.New(State, ""))
.WithCallerInfo());
Contributions are always welcome!