Skip to content

Instantly share code, notes, and snippets.

@Gosha
Last active November 1, 2018 14:18
Show Gist options
  • Save Gosha/e9830617733542fa97bed275f453d303 to your computer and use it in GitHub Desktop.
Save Gosha/e9830617733542fa97bed275f453d303 to your computer and use it in GitHub Desktop.
Graylog Exception Reproduction
obj/
bin/
out/
.git/
.vscode/
bin/
obj/
.vscode/

Fixed with:

diff --git a/GraylogSinkException.csproj b/GraylogSinkException.csproj
index e851903..ad3e7c9 100644
--- a/GraylogSinkException.csproj
+++ b/GraylogSinkException.csproj
@@ -9,7 +9,7 @@
   <ItemGroup>
     <PackageReference Include="Serilog" Version="2.7.1" />
     <PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
-    <PackageReference Include="Serilog.Sinks.Graylog" Version="2.0.2" />
+    <PackageReference Include="Serilog.Sinks.Graylog" Version="2.0.3" />
   </ItemGroup>
 
 </Project>
#!/bin/bash
TAG=graylog-exception
docker build -t $TAG . \
&& docker run --rm -it $TAG
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /app
COPY *.csproj .
RUN dotnet restore
# copy everything else and build app
COPY . .
WORKDIR /app
RUN dotnet publish -c Release -o out
# Package app
FROM microsoft/dotnet:2.1-runtime AS runtime
WORKDIR /app
COPY --from=build /app/out ./
ENTRYPOINT ["dotnet", "GraylogSinkException.dll"]
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RootNamespace>GraylogSinkException</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Serilog" Version="2.7.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.Graylog" Version="2.0.3" />
</ItemGroup>
</Project>
Sending build context to Docker daemon 8.192kB
Step 1/11 : FROM microsoft/dotnet:2.1-sdk AS build
---> d14ca4022ef8
Step 2/11 : WORKDIR /app
---> Using cache
---> 39cf6736716e
Step 3/11 : COPY *.csproj .
---> Using cache
---> 3ca17e71ebf5
Step 4/11 : RUN dotnet restore
---> Using cache
---> d65cff3b2b76
Step 5/11 : COPY . .
---> a99787ce64cb
Step 6/11 : WORKDIR /app
---> Running in 274890cdba1d
Removing intermediate container 274890cdba1d
---> 9cf17bdf4be1
Step 7/11 : RUN dotnet publish -c Release -o out
---> Running in 7443f7d93ffe
Microsoft (R) Build Engine version 15.8.166+gd4e8d81a88 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 33.27 ms for /app/GraylogSinkException.csproj.
GraylogSinkException -> /app/bin/Release/netcoreapp2.1/GraylogSinkException.dll
GraylogSinkException -> /app/out/
Removing intermediate container 7443f7d93ffe
---> 3ff03f867512
Step 8/11 : FROM microsoft/dotnet:2.1-runtime AS runtime
---> 870fda08c907
Step 9/11 : WORKDIR /app
---> Using cache
---> f997b6c084dd
Step 10/11 : COPY --from=build /app/out ./
---> Using cache
---> 2a5b7de141fd
Step 11/11 : ENTRYPOINT ["dotnet", "GraylogSinkException.dll"]
---> Using cache
---> 3625ece4af89
Successfully built 3625ece4af89
Successfully tagged graylog-exception:latest
[14:14:21 INF] Hello, Serilog!
using System;
using Serilog;
using Serilog.Sinks.Graylog;
using Serilog.Sinks.Graylog.Core;
using Serilog.Sinks.Graylog.Core.Transport;
namespace test_dotnet_core
{
class Program
{
static void Main(string[] args)
{
var log = new LoggerConfiguration()
.WriteTo.Console()
.WriteTo.Graylog(new GraylogSinkOptions
{
HostnameOrAddress = "127.0.0.1",
TransportType = TransportType.Udp,
Port = 12201
})
.CreateLogger();
Serilog.Debugging.SelfLog.Enable(msg => Console.WriteLine("Serilog: " + msg));
log.Information("Hello, Serilog!");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment