NamespaceSystemLibrary.Common.Web
ILogWriter is responsible for storing log messages
- Create a new class that implements ILogWriter
- Register your class as singleton implementation of the ILogWriter
ILogWriter is responsible for storing log messages
Program.cs/Startup.cs:
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton(typeof(YourLogWriter), typeof(ILogWriter));
}
Your LogWriter implementation:
public class YourLogWriter : ILogWriter
{
public void Error(string message)
{
//Write message to slack? CloudWatch? Sentry.io? Local disc? Its up to you
}
...
}
Usage
Log.Error("hello world");
Log.Warning("hello world");
Log.Debug("hello world");
Log.Info("hello world");
Log.Write("hello world");
All calls to method in 'Log' will create a message, append various data, and pass it to your log writer
Implement the writing of debug messages
Type | Name | Description |
---|---|---|
System.String | message |
Implement the writing of error messages
Type | Name | Description |
---|---|---|
System.String | message |
Implement the writing of info messages
Type | Name | Description |
---|---|---|
System.String | message |
Implement the writing of warning messages
Type | Name | Description |
---|---|---|
System.String | message |
Implement the writing of warning messages
Note: Write() will always be invoked, even if you disable logging in appSettings
Type | Name | Description |
---|---|---|
System.String | message |
}