Skip to content

Commit bde9579

Browse files
authored
Merge pull request #2 from ai-traders/gelf
Adds gelf support
2 parents b2c7fc4 + 1c7c9a1 commit bde9579

File tree

6 files changed

+46
-2
lines changed

6 files changed

+46
-2
lines changed

paket.dependencies

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ nuget Microsoft.Extensions.Logging.Abstractions
1616
nuget Microsoft.Extensions.Logging.Configuration
1717
nuget Microsoft.Extensions.Logging.Console
1818
nuget Microsoft.Extensions.Options.ConfigurationExtensions
19+
nuget Gelf.Extensions.Logging
1920
nuget morelinq
2021
nuget NuGet.Client
2122
nuget NuGet.Packaging

paket.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ NUGET
1414
System.ComponentModel.Annotations (>= 4.4.1)
1515
System.ComponentModel.Primitives (>= 4.3)
1616
System.ValueTuple (>= 4.5)
17+
Gelf.Extensions.Logging (1.4)
18+
Microsoft.Extensions.Logging (>= 2.0)
19+
Newtonsoft.Json (>= 10.0.3)
20+
System.Threading.Tasks.Dataflow (>= 4.8)
21+
System.ValueTuple (>= 4.4)
1722
McMaster.Extensions.CommandLineUtils (2.2.5)
1823
System.ComponentModel.Annotations (>= 4.4.1)
1924
Microsoft.AspNet.WebApi.Client (5.2.6) - restriction: || (== netcoreapp2.1) (&& (== netstandard2.0) (>= netcoreapp2.1))
@@ -1529,6 +1534,7 @@ NUGET
15291534
Microsoft.NETCore.Platforms (>= 1.1)
15301535
Microsoft.NETCore.Targets (>= 1.1)
15311536
System.Runtime (>= 4.3)
1537+
System.Threading.Tasks.Dataflow (4.9)
15321538
System.Threading.Tasks.Extensions (4.5.1)
15331539
System.Threading.Tasks.Parallel (4.3) - restriction: || (== netcoreapp2.1) (&& (== netstandard2.0) (>= netcoreapp2.1))
15341540
System.Collections.Concurrent (>= 4.3)

readme.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ About this fork:
1212
- implements read-through cache, which [does not work upstream](https://github.com/loic-sharma/BaGet/issues/93)
1313
- uses paket and FAKE for build system. [PR](https://github.com/loic-sharma/BaGet/pull/108)
1414
- uses [Carter](https://github.com/CarterCommunity/Carter) for routing rather than bare Asp routing.
15+
- adds ability to log to graylog
1516
- we intend to merge all this upstream, but review is slow and we need working server now.
1617
- we intend to move V2 from LiGet to BaGet.
1718

@@ -31,6 +32,17 @@ For persistent data, you should mount **volumes**:
3132
You should change the default api key (`NUGET-SERVER-API-KEY`) used for pushing packages,
3233
by setting SHA256 into `ApiKeyHash` environment variable.
3334

35+
### Logging to graylog
36+
37+
BaGet is using [GELF provider for Microsoft.Extensions.Logging](https://github.com/mattwcole/gelf-extensions-logging)
38+
to optionally configure logging via GELF to graylog.
39+
To configure docker image for logging to your graylog, you can set following environment variables:
40+
```
41+
Graylog__Host=your-graylog.com
42+
Graylog__Port=12201
43+
Graylog__AdditionalFields__environment=development
44+
```
45+
3446
## On client side
3547

3648
### Usage only as private repository

src/BaGet/Program.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
using BaGet.Core.Mirror;
22
using BaGet.Extensions;
3+
using Gelf.Extensions.Logging;
34
using McMaster.Extensions.CommandLineUtils;
45
using Microsoft.AspNetCore;
56
using Microsoft.AspNetCore.Hosting;
67
using Microsoft.Extensions.DependencyInjection;
78
using Microsoft.Extensions.Hosting;
9+
using Microsoft.Extensions.Logging;
810

911
namespace BaGet
1012
{
@@ -46,6 +48,17 @@ await provider
4648
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
4749
WebHost.CreateDefaultBuilder(args)
4850
.UseStartup<Startup>()
51+
.ConfigureLogging((context, builder) =>
52+
{
53+
// Read GelfLoggerOptions from appsettings.json
54+
builder.Services.Configure<GelfLoggerOptions>(context.Configuration.GetSection("Graylog"));
55+
56+
// Read Logging settings from appsettings.json and add providers.
57+
builder.AddConfiguration(context.Configuration.GetSection("Logging"))
58+
.AddConsole()
59+
.AddDebug()
60+
.AddGelf();
61+
})
4962
.UseUrls("http://0.0.0.0:9090")
5063
.UseKestrel(options =>
5164
{

src/BaGet/appsettings.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@
3333
"LogLevel": {
3434
"Default": "Warning"
3535
}
36+
},
37+
"GELF": {
38+
"IncludeScopes": true,
39+
"LogLevel": {
40+
"Default": "Information"
41+
}
3642
}
43+
},
44+
"Graylog": {
45+
"Host": "localhost",
46+
"Port": 12201,
47+
"LogSource": "baget"
3748
}
38-
}
49+
}

src/BaGet/paket.references

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ Microsoft.Data.SQLite
44
Microsoft.EntityFrameworkCore.Sqlite
55
Microsoft.Extensions.Logging.Configuration
66
Microsoft.Extensions.Logging.Console
7-
NuGet.Client
7+
Gelf.Extensions.Logging
8+
NuGet.Client

0 commit comments

Comments
 (0)