MondoCore.Log
2.2.0
See the version list below for details.
dotnet add package MondoCore.Log --version 2.2.0
NuGet\Install-Package MondoCore.Log -Version 2.2.0
<PackageReference Include="MondoCore.Log" Version="2.2.0" />
<PackageVersion Include="MondoCore.Log" Version="2.2.0" />
<PackageReference Include="MondoCore.Log" />
paket add MondoCore.Log --version 2.2.0
#r "nuget: MondoCore.Log, 2.2.0"
#:package MondoCore.Log@2.2.0
#addin nuget:?package=MondoCore.Log&version=2.2.0
#tool nuget:?package=MondoCore.Log&version=2.2.0
MondoCore.Log
Classes for logging
<br>
Dependency Injection
In your dependency injection code create a singleton instance of Log
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
// Register the main Log class as a singleton.
builder.Services.AddSingleton<ILog>( (p)=>
{
var log = new Log();
// Use GetService to get the TelemetryConfiguration to share with the host
log.Register( new ApplicationInsights( p.GetService<TelemetryConfiguration>() ),
new Splunk("???"), types: new List<Telemetry.TelemetryType> { Telemetry.TelemetryType.Event } ); // Log only WriteEvent telemetry
return log;
);
// Register IRequestLog as scoped. That same instance will be returned within the scope of a function invocation
builder.Services.AddScoped<IRequestLog, RequestLog>();
}
}
<br>
Logging with ILog
Inject the ILog interface
using MondoCore.Log;
public class CoolClass
{
private readonly ILog _log;
public CoolClass(ILog log)
{
_log = log;
}
public async Task DoSomething(string name)
{
try
{
_log.WriteEvent("Something cool", new {Make = "Chevy", Model = "Corvette", Name = name } );
if(blah)
await _log.WriteError(new Exception("Data error"), Telemetry.LogSeverity.Warning, new { Class = "CoolClass", Function = "DoSomething" } )
}
catch(Exception ex)
{
// The anonymous object will be logged as two properties: "Class" and "Function"
await _log.WriteError(ex, Telemetry.LogSeverity.Critical, new { Class = "CoolClass", Function = "DoSomething" } )
}
}
}
<br>
Logging with IRequestLog
By creating a scoped RequestLog you can set properties that will exist for every log within that scope. IRequestLog is derived from ILog so you just treat it as an ILog
using MondoCore.Log;
public class CoolClass
{
private readonly IRequestLog _log;
public CoolClass(IRequestLog log)
{
_log = log;
}
public async Task DoSomething(string name)
{
// This property will be added to all subsequent log calls during the lifetime of IRequestLog
_log.SetProperty("Name", name);
try
{
// Do something...
// ...
_log.WriteEvent("Something cool", new {Make = "Chevy", Model = "Corvette"} );
if(blah)
await _log.WriteError(new Exception("Data error"), Telemetry.LogSeverity.Warning, new { Class = "CoolClass", Function = "DoSomething" } )
}
catch(Exception ex)
{
// The anonymous object will be logged as two properties: "Class" and "Function"
await _log.WriteError(ex, new { Class = "CoolClass", Function = "DoSomething" } )
}
}
// Nested IRequestLog
public async Task DoSomethingElse(string name)
{
using(var requestLog = log.NewRequest("CoolClass.DoSomethingElse))
{
// These properties will be added to all log calls within this using block (you must use the local log var)
requestLog.SetProperty("Name", name);
requestLog.SetProperty("Class", nameof(CoolClass));
requestLog.SetProperty("Method", nameof(DoSomethingElse));
try
{
// Do something...
// ...
requestLog.WriteEvent("Something cool", new {Make = "Chevy", Model = "Corvette"} );
if(blah)
await requestLog.WriteError(new Exception("Data error"), Telemetry.LogSeverity.Warning)
}
catch(Exception ex)
{
await requestLog.WriteError(ex)
}
}
}
}
<br>
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
NuGet packages (3)
Showing the top 3 NuGet packages that depend on MondoCore.Log:
| Package | Downloads |
|---|---|
|
MondoCore.Azure.ApplicationInsights
Implementation of ILog interface for Application Insights |
|
|
MondoCore.ApplicationInsights
Implementation of ILog interface for Application Insights |
|
|
MondoCore.Data.Log
A ILog (MondoCore.Log) wrapper around the IWriteRespository in MondoCore.Data to write telemetry to a database |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.4.1 | 126 | 2/13/2026 |
| 2.4.0 | 140 | 2/10/2026 |
| 2.3.1 | 117 | 2/9/2026 |
| 2.3.0 | 277 | 11/30/2024 |
| 2.2.1 | 223 | 10/9/2024 |
| 2.2.0 | 233 | 9/30/2024 |
| 2.1.0 | 170 | 7/23/2024 |
| 2.0.0 | 3,610 | 11/26/2023 |
| 1.6.0 | 2,420 | 10/6/2023 |
| 1.5.1 | 1,800 | 3/20/2021 |
| 1.5.0 | 675 | 2/20/2021 |
| 1.4.0 | 661 | 2/8/2021 |
| 1.3.0 | 704 | 1/27/2021 |
| 1.2.1 | 723 | 1/10/2021 |
| 1.2.0 | 855 | 12/6/2020 |
| 1.1.0 | 822 | 9/19/2020 |
| 1.0.1 | 740 | 8/31/2020 |
| 1.0.0 | 918 | 8/8/2020 |
Add availability telemetry