Skip to content

Updated to work on the latest libraries and .net Standard 2.0. #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Example/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,12 @@
<add key="Stackify.Environment" value="" />
<add key="Stackify.ApiKey" value="" />
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
18 changes: 10 additions & 8 deletions Example/Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,27 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
<HintPath>..\packages\Serilog.2.0.0\lib\net45\Serilog.dll</HintPath>
<HintPath>..\packages\Serilog.2.8.0\lib\net45\Serilog.dll</HintPath>
</Reference>
<Reference Include="Serilog.Sinks.Stackify, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Serilog.Sinks.Stackify.2.0.2\lib\net45\Serilog.Sinks.Stackify.dll</HintPath>
<Reference Include="Serilog.Sinks.Stackify, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Serilog.Sinks.Stackify.2.1.0\lib\net45\Serilog.Sinks.Stackify.dll</HintPath>
</Reference>
<Reference Include="StackifyLib, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\StackifyLib.2.0.0\lib\net45\StackifyLib.dll</HintPath>
<Reference Include="StackifyLib, Version=2.1.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\StackifyLib.2.1.4\lib\net45\StackifyLib.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Management" />
<Reference Include="System.Numerics" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand Down
2 changes: 1 addition & 1 deletion Example/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static void ConfigureLogging()
{
Log.Logger = new LoggerConfiguration()
.WriteTo
.Stackify()
.Stackify("", "", "")
.CreateLogger();
}
}
Expand Down
8 changes: 4 additions & 4 deletions Example/packages.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
<package id="Serilog" version="2.0.0" targetFramework="net45" />
<package id="Serilog.Sinks.Stackify" version="2.0.2" targetFramework="net45" />
<package id="StackifyLib" version="2.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net45" />
<package id="Serilog" version="2.8.0" targetFramework="net45" />
<package id="Serilog.Sinks.Stackify" version="2.1.0" targetFramework="net45" />
<package id="StackifyLib" version="2.1.4" targetFramework="net45" />
</packages>
6 changes: 3 additions & 3 deletions Serilog.Sinks.Stackify.sln
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26621.2
# Visual Studio Version 16
VisualStudioVersion = 16.0.28917.181
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example", "Example\Example.csproj", "{50C48CCC-8551-459A-A306-95D84DC3A422}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Sinks.Stackify", "Serilog.Sinks.Stackify\Serilog.Sinks.Stackify.csproj", "{E44EC161-7AEF-40F1-9FFC-C98A3F105F23}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Sinks.Stackify", "Serilog.Sinks.Stackify\Serilog.Sinks.Stackify.csproj", "{E44EC161-7AEF-40F1-9FFC-C98A3F105F23}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
15 changes: 11 additions & 4 deletions Serilog.Sinks.Stackify/LoggerConfigurationStackifyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,27 @@ public static class LoggerConfigurationStackifyExtensions
/// Adds a sink that writes log events to the elmah.io webservice.
/// </summary>
/// <param name="loggerConfiguration">The logger configuration.</param>
/// <param name="apiKey">The api key provided by Stackify.</param>
/// <param name="appName">The name of your application.</param>
/// <param name="environment">The name of the environment, e.g. Dev / Prod / Stage etc.</param>
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
/// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink. Set to Verbose by default.</param>
/// <returns>Logger configuration, allowing configuration to continue.</returns>
/// <exception cref="ArgumentNullException">A required parameter is null.</exception>
public static LoggerConfiguration Stackify(
this LoggerSinkConfiguration loggerConfiguration,
string apiKey,
string appName = "",
string environment = "",
IFormatProvider formatProvider = null,
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum
)
{
if (loggerConfiguration == null) throw new ArgumentNullException("loggerConfiguration");

{
if (loggerConfiguration == null) throw new ArgumentNullException(nameof(loggerConfiguration));
if (string.IsNullOrWhiteSpace(apiKey)) throw new ArgumentNullException(nameof(apiKey));

return loggerConfiguration
.Sink(new StackifySink(formatProvider), restrictedToMinimumLevel);
.Sink(new StackifySink(formatProvider, apiKey, appName, environment), restrictedToMinimumLevel);
}
}
}
20 changes: 10 additions & 10 deletions Serilog.Sinks.Stackify/Serilog.Sinks.Stackify.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard1.3;net45</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
<PackageId>Serilog.Sinks.Stackify</PackageId>
<Version>2.0.2</Version>
<Version>2.1.0</Version>
<Authors>Serilog.Sinks.Stackify</Authors>
<Company>Stackify</Company>
<Product>Serilog Stackify Sink</Product>
Expand All @@ -19,18 +19,18 @@
<AssemblyName>Serilog.Sinks.Stackify</AssemblyName>
<RootNamespace>Serilog.Sinks.Stackify</RootNamespace>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<FileVersion>2.0.0.0</FileVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
<FileVersion>2.1.0.0</FileVersion>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<PackageReference Include="Serilog" Version="2.0.0" />
<PackageReference Include="StackifyLib" Version="2.0.0" />
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Serilog" Version="2.8.0" />
<PackageReference Include="StackifyLib" Version="2.1.4" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<PackageReference Include="Serilog" Version="2.0.0" />
<PackageReference Include="StackifyLib" Version="2.0.0" />
<PackageReference Include="Serilog" Version="2.8.0" />
<PackageReference Include="StackifyLib" Version="2.1.4" />
</ItemGroup>

</Project>
12 changes: 11 additions & 1 deletion Serilog.Sinks.Stackify/Sinks/Stackify/StackifySink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,28 @@ public class StackifySink : ILogEventSink, IDisposable
{
private readonly ErrorGovernor _Governor = new ErrorGovernor();
private readonly IFormatProvider _formatProvider;
private readonly string _apiKey;
private readonly string _appName;
private readonly string _environment;
private readonly JsonDataFormatter _dataFormatter;
private LogClient _logClient = null;

/// <summary>
/// Construct a sink that saves logs to the specified storage account.
/// </summary>
public StackifySink(IFormatProvider formatProvider)
public StackifySink(IFormatProvider formatProvider, string apiKey, string appName, string environment)
{
_formatProvider = formatProvider;
_apiKey = apiKey;
_appName = appName;
_environment = environment;

_dataFormatter = new JsonDataFormatter();
_logClient = new LogClient("StackifyLib.net-serilog", null, null);

Config.ApiKey = apiKey;
Config.AppName = appName;
Config.Environment = environment;
}


Expand Down