diff --git a/.gitignore b/.gitignore
index fd5204b..6cd4bdb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -181,3 +181,6 @@ UpgradeLog*.htm
# Microsoft Fakes
FakesAssemblies/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
\ No newline at end of file
diff --git a/Build.ps1 b/Build.ps1
index 185d930..3574ff0 100644
--- a/Build.ps1
+++ b/Build.ps1
@@ -1,85 +1,37 @@
-param(
- [String] $majorMinor = "0.0", # 2.0
- [String] $patch = "0", # $env:APPVEYOR_BUILD_VERSION
- [String] $customLogger = "", # C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll
- [Switch] $notouch,
- [String] $sln # e.g serilog-sink-name
-)
+echo "build: Build started"
-function Set-AssemblyVersions($informational, $assembly)
-{
- (Get-Content assets/CommonAssemblyInfo.cs) |
- ForEach-Object { $_ -replace """1.0.0.0""", """$assembly""" } |
- ForEach-Object { $_ -replace """1.0.0""", """$informational""" } |
- ForEach-Object { $_ -replace """1.1.1.1""", """$($informational).0""" } |
- Set-Content assets/CommonAssemblyInfo.cs
-}
-
-function Install-NuGetPackages($solution)
-{
- nuget restore $solution
-}
-
-function Invoke-MSBuild($solution, $customLogger)
-{
- if ($customLogger)
- {
- msbuild "$solution" /verbosity:minimal /p:Configuration=Release /logger:"$customLogger"
- }
- else
- {
- msbuild "$solution" /verbosity:minimal /p:Configuration=Release
- }
-}
+Push-Location $PSScriptRoot
-function Invoke-NuGetPackProj($csproj)
-{
- nuget pack -Prop Configuration=Release -Symbols $csproj
+if(Test-Path .\artifacts) {
+ echo "build: Cleaning .\artifacts"
+ Remove-Item .\artifacts -Force -Recurse
}
-function Invoke-NuGetPackSpec($nuspec, $version)
-{
- nuget pack $nuspec -Version $version -OutputDirectory ..\..\
-}
+& dotnet restore --no-cache
-function Invoke-NuGetPack($version)
-{
- ls src/**/*.csproj |
- Where-Object { -not ($_.Name -like "*net40*") } |
- ForEach-Object { Invoke-NuGetPackProj $_ }
-}
+$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
+$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
+$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"]
+$commitHash = $(git rev-parse --short HEAD)
+$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]
-function Invoke-Build($majorMinor, $patch, $customLogger, $notouch, $sln)
-{
- $package="$majorMinor.$patch"
- $slnfile = "$sln.sln"
+echo "build: Package version suffix is $suffix"
+echo "build: Build version suffix is $buildSuffix"
- Write-Output "$sln $package"
+foreach ($src in ls src/*) {
+ Push-Location $src
- if (-not $notouch)
- {
- $assembly = "$majorMinor.0.0"
+ echo "build: Packaging project in $src"
- Write-Output "Assembly version will be set to $assembly"
- Set-AssemblyVersions $package $assembly
+ & dotnet build -c Release --version-suffix=$buildSuffix
+ if ($suffix) {
+ & dotnet pack -c Release --include-source -o ..\..\artifacts --version-suffix=$suffix --no-build
+ } else {
+ & dotnet pack -c Release --include-source -o ..\..\artifacts --no-build
}
+ if($LASTEXITCODE -ne 0) { exit 1 }
- Install-NuGetPackages $slnfile
-
- Invoke-MSBuild $slnfile $customLogger
-
- Invoke-NuGetPack $package
-}
-
-$ErrorActionPreference = "Stop"
-
-if (-not $sln)
-{
- $slnfull = ls *.sln |
- Where-Object { -not ($_.Name -like "*net40*") } |
- Select -first 1
-
- $sln = $slnfull.BaseName
+ Pop-Location
}
-Invoke-Build $majorMinor $patch $customLogger $notouch $sln
+Pop-Location
\ No newline at end of file
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..9cdbbb1
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,25 @@
+version: '{build}'
+skip_tags: true
+image: Visual Studio 2017
+configuration: Release
+install:
+ - ps: mkdir -Force ".\build\" | Out-Null
+build_script:
+- ps: ./Build.ps1
+test: off
+artifacts:
+- path: artifacts/Serilog.*.nupkg
+deploy:
+- provider: NuGet
+ api_key:
+ secure: nvZ/z+pMS91b3kG4DgfES5AcmwwGoBYQxr9kp4XiJHj25SAlgdIxFx++1N0lFH2x
+ skip_symbols: true
+ on:
+ branch: /^(master|dev)$/
+- provider: GitHub
+ auth_token:
+ secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX
+ artifact: /Serilog.*\.nupkg/
+ tag: v$(appveyor_build_version)
+ on:
+ branch: master
\ No newline at end of file
diff --git a/assets/CommonAssemblyInfo.cs b/assets/CommonAssemblyInfo.cs
deleted file mode 100644
index 0f5c380..0000000
--- a/assets/CommonAssemblyInfo.cs
+++ /dev/null
@@ -1,5 +0,0 @@
-using System.Reflection;
-
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.1.1.1")]
-[assembly: AssemblyInformationalVersion("1.0.0")]
diff --git a/serilog-sinks-azureeventhub.sln b/serilog-sinks-azureeventhub.sln
index 7970b24..489e7c7 100644
--- a/serilog-sinks-azureeventhub.sln
+++ b/serilog-sinks-azureeventhub.sln
@@ -1,9 +1,9 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2013
-VisualStudioVersion = 12.0.31101.0
+# Visual Studio 15
+VisualStudioVersion = 15.0.27004.2009
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Sinks.AzureEventHub", "src\Serilog.Sinks.AzureEventHub\Serilog.Sinks.AzureEventHub.csproj", "{F779C831-866F-4B87-B733-1BD1DB1E1606}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Sinks.AzureEventHub", "src\Serilog.Sinks.AzureEventHub\Serilog.Sinks.AzureEventHub.csproj", "{4F30F48A-E294-456B-810F-E6D5B0191421}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -11,12 +11,15 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {F779C831-866F-4B87-B733-1BD1DB1E1606}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {F779C831-866F-4B87-B733-1BD1DB1E1606}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {F779C831-866F-4B87-B733-1BD1DB1E1606}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {F779C831-866F-4B87-B733-1BD1DB1E1606}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4F30F48A-E294-456B-810F-E6D5B0191421}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4F30F48A-E294-456B-810F-E6D5B0191421}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4F30F48A-E294-456B-810F-E6D5B0191421}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4F30F48A-E294-456B-810F-E6D5B0191421}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {E0B607D3-51F2-4422-AD79-617F980AE0F1}
+ EndGlobalSection
EndGlobal
diff --git a/src/Serilog.Sinks.AzureEventHub/LoggerConfigurationAzureEventHubExtensions.cs b/src/Serilog.Sinks.AzureEventHub/LoggerConfigurationAzureEventHubExtensions.cs
index 6133fce..8b7821d 100644
--- a/src/Serilog.Sinks.AzureEventHub/LoggerConfigurationAzureEventHubExtensions.cs
+++ b/src/Serilog.Sinks.AzureEventHub/LoggerConfigurationAzureEventHubExtensions.cs
@@ -14,7 +14,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
-using Microsoft.ServiceBus.Messaging;
+using Microsoft.Azure.EventHubs;
using Serilog.Configuration;
using Serilog.Core;
using Serilog.Events;
@@ -153,7 +153,12 @@ public static LoggerConfiguration AzureEventHub(
if (string.IsNullOrWhiteSpace(eventHubName))
throw new ArgumentNullException("eventHubName");
- var client = EventHubClient.CreateFromConnectionString(connectionString, eventHubName);
+ var connectionstringBuilder = new EventHubsConnectionStringBuilder(connectionString)
+ {
+ EntityPath = eventHubName
+ };
+
+ var client = EventHubClient.CreateFromConnectionString(connectionstringBuilder.ToString());
return AzureEventHub(loggerConfiguration, client, outputTemplate, formatProvider, restrictedToMinimumLevel, writeInBatches, period, batchPostingLimit);
}
@@ -190,7 +195,11 @@ public static LoggerConfiguration AzureEventHub(
if (string.IsNullOrWhiteSpace(eventHubName))
throw new ArgumentNullException("eventHubName");
- var client = EventHubClient.CreateFromConnectionString(connectionString, eventHubName);
+ var connectionStringBuilder = new EventHubsConnectionStringBuilder(connectionString)
+ {
+ EntityPath = eventHubName
+ };
+ var client = EventHubClient.CreateFromConnectionString(connectionStringBuilder.ToString());
return AzureEventHub(loggerConfiguration, formatter, client, restrictedToMinimumLevel, writeInBatches, period, batchPostingLimit);
}
diff --git a/src/Serilog.Sinks.AzureEventHub/Properties/AssemblyInfo.cs b/src/Serilog.Sinks.AzureEventHub/Properties/AssemblyInfo.cs
deleted file mode 100644
index d621a1a..0000000
--- a/src/Serilog.Sinks.AzureEventHub/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-
-[assembly: AssemblyTitle("Serilog.Sinks.AzureEventHub")]
-[assembly: AssemblyDescription("Serilog sink for Azure Event Hub")]
-[assembly: AssemblyCopyright("Copyright © Serilog Contributors 2015")]
-
-[assembly: InternalsVisibleTo("Serilog.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100fb8d13fd344a1c" +
- "6fe0fe83ef33c1080bf30690765bc6eb0df26ebfdf8f21670c64265b30db09f73a0dea5b3db4c9" +
- "d18dbf6d5a25af5ce9016f281014d79dc3b4201ac646c451830fc7e61a2dfd633d34c39f87b818" +
- "94191652df5ac63cc40c77f3542f702bda692e6e8a9158353df189007a49da0f3cfd55eb250066" +
- "b19485ec")]
\ No newline at end of file
diff --git a/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj b/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj
index ca63295..e9ffaad 100644
--- a/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj
+++ b/src/Serilog.Sinks.AzureEventHub/Serilog.Sinks.AzureEventHub.csproj
@@ -1,95 +1,32 @@
-
-
-
-
- Debug
- AnyCPU
- {F779C831-866F-4B87-B733-1BD1DB1E1606}
- Library
- Properties
- Serilog
- Serilog.Sinks.AzureEventHub
- v4.5
- 512
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
- bin\Debug\Serilog.Sinks.AzureEventHub.XML
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
- true
-
-
- ..\..\assets\Serilog.snk
-
-
-
- ..\..\packages\WindowsAzure.ServiceBus.3.4.0\lib\net45-full\Microsoft.ServiceBus.dll
- True
-
-
- ..\..\packages\Microsoft.WindowsAzure.ConfigurationManager.3.2.1\lib\net40\Microsoft.WindowsAzure.Configuration.dll
- True
-
-
- ..\..\packages\Serilog.2.3.0\lib\net45\Serilog.dll
- True
-
-
- ..\..\packages\Serilog.Sinks.PeriodicBatching.2.0.1\lib\net45\Serilog.Sinks.PeriodicBatching.dll
- True
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Properties\CommonAssemblyInfo.cs
-
-
-
-
-
-
-
-
- Serilog.snk
-
-
-
-
- Designer
-
-
-
-
-
\ No newline at end of file
+
+
+
+ Write Serilog events to Azure Event Hub
+ 4.0.0
+ Serilog Contributors
+ netstandard2.0
+ true
+ Serilog.Sinks.AzureEventHub
+ ../../assets/Serilog.snk
+ true
+ true
+ Serilog.Sinks.AzureEventHub
+ serilog;;azure;eventhub
+ http://serilog.net/images/serilog-sink-nuget.png
+ http://serilog.net
+ http://www.apache.org/licenses/LICENSE-2.0
+ false
+ Serilog
+ true
+
+ true
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Serilog.Sinks.AzureEventHub/Sinks/AzureEventHub/AzureEventHubBatchingSink.cs b/src/Serilog.Sinks.AzureEventHub/Sinks/AzureEventHub/AzureEventHubBatchingSink.cs
index b02ab87..cc2b7eb 100644
--- a/src/Serilog.Sinks.AzureEventHub/Sinks/AzureEventHub/AzureEventHubBatchingSink.cs
+++ b/src/Serilog.Sinks.AzureEventHub/Sinks/AzureEventHub/AzureEventHubBatchingSink.cs
@@ -17,7 +17,7 @@
using System.IO;
using System.Text;
using System.Threading.Tasks;
-using Microsoft.ServiceBus.Messaging;
+using Microsoft.Azure.EventHubs;
using Serilog.Events;
using Serilog.Formatting;
using Serilog.Sinks.PeriodicBatching;
@@ -29,8 +29,8 @@ namespace Serilog.Sinks.AzureEventHub
///
public class AzureEventHubBatchingSink : PeriodicBatchingSink
{
- readonly EventHubClient _eventHubClient;
- readonly ITextFormatter _formatter;
+ private readonly EventHubClient _eventHubClient;
+ private readonly ITextFormatter _formatter;
///
/// Construct a sink that saves log events to the specified EventHubClient.
@@ -76,16 +76,13 @@ protected override Task EmitBatchAsync(IEnumerable events)
_formatter.Format(logEvent, render);
body = Encoding.UTF8.GetBytes(render.ToString());
}
- var eventHubData = new EventData(body)
- {
- PartitionKey = batchPartitionKey
- };
+ var eventHubData = new EventData(body);
+
eventHubData.Properties.Add("Type", "SerilogEvent");
batchedEvents.Add(eventHubData);
}
-
- return _eventHubClient.SendBatchAsync(batchedEvents);
+ return _eventHubClient.SendAsync(batchedEvents, batchPartitionKey);
}
}
}
diff --git a/src/Serilog.Sinks.AzureEventHub/Sinks/AzureEventHub/AzureEventHubSink.cs b/src/Serilog.Sinks.AzureEventHub/Sinks/AzureEventHub/AzureEventHubSink.cs
index 395938f..afcd048 100644
--- a/src/Serilog.Sinks.AzureEventHub/Sinks/AzureEventHub/AzureEventHubSink.cs
+++ b/src/Serilog.Sinks.AzureEventHub/Sinks/AzureEventHub/AzureEventHubSink.cs
@@ -15,7 +15,7 @@
using System;
using System.IO;
using System.Text;
-using Microsoft.ServiceBus.Messaging;
+using Microsoft.Azure.EventHubs;
using Serilog.Core;
using Serilog.Events;
using Serilog.Formatting;
@@ -55,13 +55,12 @@ public void Emit(LogEvent logEvent)
_formatter.Format(logEvent, render);
body = Encoding.UTF8.GetBytes(render.ToString());
}
- var eventHubData = new EventData(body)
- {
- PartitionKey = Guid.NewGuid().ToString()
- };
+ var eventHubData = new EventData(body);
eventHubData.Properties.Add("Type", "SerilogEvent");
- _eventHubClient.Send(eventHubData);
+ //Unfortunately no support for async in Serilog yet
+ //https://github.com/serilog/serilog/issues/134
+ _eventHubClient.SendAsync(eventHubData, Guid.NewGuid().ToString()).GetAwaiter().GetResult();
}
}
}
\ No newline at end of file
diff --git a/src/Serilog.Sinks.AzureEventHub/app.config b/src/Serilog.Sinks.AzureEventHub/app.config
index 13e8220..1b7ec78 100644
--- a/src/Serilog.Sinks.AzureEventHub/app.config
+++ b/src/Serilog.Sinks.AzureEventHub/app.config
@@ -1,21 +1,21 @@
-
+
+ serviceUri=""/>
+ serviceUri="" cacheTimeout="86400"/>
@@ -23,26 +23,41 @@
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
\ No newline at end of file
+
diff --git a/src/Serilog.Sinks.AzureEventHub/packages.config b/src/Serilog.Sinks.AzureEventHub/packages.config
deleted file mode 100644
index f8d54d7..0000000
--- a/src/Serilog.Sinks.AzureEventHub/packages.config
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file