dotnet add package RestSharp.Serilog.Auto.Extented --version
NuGet\Install-Package RestSharp.Serilog.Auto.Extented -Version
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RestSharp.Serilog.Auto.Extented" Version="" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RestSharp.Serilog.Auto.Extented --version
#r "nuget: RestSharp.Serilog.Auto.Extented,"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install RestSharp.Serilog.Auto.Extented as a Cake Addin
#addin nuget:?package=RestSharp.Serilog.Auto.Extented&version=

// Install RestSharp.Serilog.Auto.Extented as a Cake Tool
#tool nuget:?package=RestSharp.Serilog.Auto.Extented&version=


Do you need log all communication made with RestSharp using your serilog configuration? Just install this package and register our client proxy for IRestClient.

IRestClient client = new RestClientAutolog("");

Install via NuGet

PM> Install-Package RestSharp.Serilog.Auto.Extented

How to use

You can change error message, success message and logger configuration.

var loggerConfiguration = new LoggerConfiguration()
                .Enrich.WithProperty("Domain", "MyDomain")
                .Enrich.WithProperty("Application", "MyProject")

var restClientAutologConfiguration = new RestClientAutologConfiguration()
    MessageTemplateForSuccess = "{Method} {Uri} responded {StatusCode}", 
    MessageTemplateForError = "{Method} {Uri} is not good! {ErrorMessage}", 
    LoggerConfiguration = loggerConfiguration

IRestClient client = new RestClientAutolog("", restClientAutologConfiguration);

Serilog uses Log.Logger as global. If you setup this on your application Startup/Bootstrap, it's not needed change logger configuration.

Variables to use in message templates

Properties created like (...).Enrich.WithProperty("Application", "MyProject") can be used in templates.

Default variables:

  • Agent
  • ElapsedMilliseconds
  • Method
  • Uri
  • Host
  • Path
  • Query
  • Body
  • RequestHeaders
  • StatusCode
  • StatusDescription
  • ResponseStatus
  • ProtocolVersion
  • IsSuccessful
  • ErrorMessage
  • ErrorException
  • Content
  • ContentEncoding
  • ContentLength
  • ContentType
  • ResponseHeaders
Product 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. 
.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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated 2,431 11/6/2019 503 11/6/2019
1.1.13 531 8/15/2019
1.1.12 495 8/15/2019
1.1.0 507 8/15/2019

Forked from
Extended with ExecuteTaskAsync