Code Monkey home page Code Monkey logo

elmah.io.client's Introduction

Elmah.Io.Client

Build status NuGet

Raw client for communicating with the elmah.io API.

Usage

To start logging, create a new instance of the ElmahioAPI class:

client = ElmahioAPI.Create(apiKey);

where apiKey is your API key found on your profile page at elmah.io. Make sure to share this instance as a singleton.

Logging

Log messages either through the log method:

client.Messages.Log(logId, new Exception(), Severity.Error, "This is a bug");

or through one of the helpers:

client.Messages.Debug(logId, "A debug message");
client.Messages.Fatal(logId, exception, "This is a fatal bug");

Creating logs

Logs are containers for log messages. To create a new log for a new application, microservice or similar, use the Create method:

client.Logs.Create(new CreateLog("My log"));

Developing

Parts of this client is auto generated using NSwag. NSwag is an Open Source tool that can generate clients for many languages (like C#) from Swagger/OpenAPI 2.0 and 3.0 specs.

To generate a client from the most reason API specs, you first need to install NSwag. We recommend that you use the NPM package which can be installed with this:

npm install nswag -g

With this NSwag CLI tool, you can execute the following command in this folder to generate the newest client.

nswag run

elmah.io.client's People

Contributors

kristofferstrube avatar thomasardal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

elmah.io.client's Issues

Issue with Logging

I get an exception when using Elmah in my asp.net core project.
The Exception is: "Input string was not in a correct format."
It looks like EF Core is trying to add a debug entry the sql query it is running, when elmah is trying to parse the message it throws an exception.

I assume this happen when trying to create the title in Message.Logger
Title = string.Format(messageTemplate, propertyValues),

"   at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)\r\n   
at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)\r\n   
at System.String.Format(String format, Object[] args)\r\n   
at Elmah.Io.Client.Messages.Log(Guid logId, Exception exception, Severity severity, String messageTemplate, Object[] propertyValues)\r\n   
at Elmah.Io.Extensions.Logging.ElmahIoLogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)\r\n   
at Microsoft.Extensions.Logging.Logger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)"

Periodic socket exceptions

Hi, we're occationally getting errors while publishing health checks. Are we missing something with configuration or should the default ElmahioAPI.Create's HttpContext be using Polly or something similar to provide automatic retries for transient failures?

Exception: Health check "Elmah.Io.AspNetCore.HealthChecks.ElmahIoPublisher" threw an unhandled exception after 1.8186ms
Exception stack trace:

System.Net.Http.HttpRequestException: An error occurred while sending the request.
 ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host..
 ---> System.Net.Sockets.SocketException (10054): An existing connection was forcibly closed by the remote host.
   --- End of inner exception stack trace ---
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Int32>.GetResult(Int16 token)
   at System.Net.Security.SslStream.ReadAsyncInternal[TIOAdapter](Memory`1 buffer, CancellationToken cancellationToken)
   at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
   at System.Net.Http.HttpConnection.<CheckUsabilityOnScavenge>g__ReadAheadWithZeroByteReadAsync|44_0()
   at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
   at Elmah.Io.Client.HeartbeatsClient.CreateAsync(String id, String logId, CreateHeartbeat body, CancellationToken cancellationToken) in /_/src/Elmah.Io.Client/ElmahioClient.cs:line 802
   at Elmah.Io.AspNetCore.HealthChecks.ElmahIoPublisher.PublishAsync(HealthReport report, CancellationToken cancellationToken) in /_/src/Elmah.Io.AspNetCore.HealthChecks/ElmahIoPublisher.cs:line 79
   at Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckPublisherHostedService.RunPublisherAsync(IHealthCheckPublisher publisher, HealthReport report, CancellationToken cancellationToken)
   at Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckPublisherHostedService.RunAsyncCore(CancellationToken cancellationToken)
   at Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckPublisherHostedService.RunAsync()

Add NetStandard2.0 target framework

This will reduce dependencies for NetCore-applications. Avoids NetCore1-dependencies for NetCore3-applications

Need to update Microsoft.Rest.ClientRuntime to ver. 2.3.20 (or newer) for netstandard2.0 + netstandard1.4.

P.S. Any reason why Net45 is not depending on System.Net.Http ? And why are Net46 + NetStandard1 depending on such an old version of System.Net.Http ? Remember NetStandard2.0 does not need dependency on System.Net.Http.

P.P.S. Consider changing Net46 into Net461 so it depends on same nuget-versions as NetStandard2.0 (Leaving net45 + nestandard1.1 as the special ones)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.