EGC.MLog.Client 1.0.4

MLog Connector (.NET Framework)

There is a newer version of this package available.
See the version list below for details.
Install-Package EGC.MLog.Client -Version 1.0.4
dotnet add package EGC.MLog.Client --version 1.0.4
<PackageReference Include="EGC.MLog.Client" Version="1.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EGC.MLog.Client --version 1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Usage example

// ...

static void Main(string[] args)
{
	// Get certificate from store
	var certificate = GetCertificate(StoreLocation.LocalMachine, X509FindType.FindBySubjectName, "organization.pki.gov.md");
	// Initialize MLogClient
	var client = new MLogClient(new Uri("https://{{ host }}:{{ port }}"), certificate);
	// Create new MLogEvent
	var @event = new MLogEvent("event.type");
	// Set the event proeprties
	@event.Subject = new []{ "Subject 1", "Subject 2"};
	// ...

	// Register event in MLog
	var response = client.RegisterEvent(@event);

	// Display register result
	Console.WriteLine("MLog register event response: {0}", response);

	Console.WriteLine("Press [ENTER] to close this window.");
	Console.Read();
}

private static X509Certificate2 GetCertificate(StoreLocation storeLocation, X509FindType findType, string findValue)
{
	using (var store = new X509Store(StoreName.My, storeLocation))
	{
		store.Open(OpenFlags.ReadOnly);
		var certificates = store.Certificates.Find(findType, findValue, true);
		if (certificates.Count == 0)
		{
			throw new OperationCanceledException($"Cannot find certificates with criteria: {findType} = {findValue}");
		}
		return certificates[0];
	}
}

Usage example

// ...

static void Main(string[] args)
{
	// Get certificate from store
	var certificate = GetCertificate(StoreLocation.LocalMachine, X509FindType.FindBySubjectName, "organization.pki.gov.md");
	// Initialize MLogClient
	var client = new MLogClient(new Uri("https://{{ host }}:{{ port }}"), certificate);
	// Create new MLogEvent
	var @event = new MLogEvent("event.type");
	// Set the event proeprties
	@event.Subject = new []{ "Subject 1", "Subject 2"};
	// ...

	// Register event in MLog
	var response = client.RegisterEvent(@event);

	// Display register result
	Console.WriteLine("MLog register event response: {0}", response);

	Console.WriteLine("Press [ENTER] to close this window.");
	Console.Read();
}

private static X509Certificate2 GetCertificate(StoreLocation storeLocation, X509FindType findType, string findValue)
{
	using (var store = new X509Store(StoreName.My, storeLocation))
	{
		store.Open(OpenFlags.ReadOnly);
		var certificates = store.Certificates.Find(findType, findValue, true);
		if (certificates.Count == 0)
		{
			throw new OperationCanceledException($"Cannot find certificates with criteria: {findType} = {findValue}");
		}
		return certificates[0];
	}
}

Release Notes

First release

Dependencies

This package has no dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.2.0 525 6/7/2018
1.1.0 305 4/20/2018
1.0.4 399 1/10/2018
1.0.3 343 1/4/2018