Skip to content

Commit 0688e2c

Browse files
authored
Merge pull request #29 from datalust/dev
1.0.0 Release
2 parents 8fa173b + 99fbc25 commit 0688e2c

26 files changed

+1023
-3
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Auto detect text files and perform LF normalization
2+
3+
* text=auto

Build.ps1

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# This script originally (c) 2016 Serilog Contributors - license Apache 2.0
2+
3+
echo "build: Build started"
4+
5+
Push-Location $PSScriptRoot
6+
7+
if(Test-Path .\artifacts) {
8+
echo "build: Cleaning .\artifacts"
9+
Remove-Item .\artifacts -Force -Recurse
10+
}
11+
12+
& dotnet restore --no-cache
13+
14+
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
15+
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
16+
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"]
17+
18+
echo "build: Version suffix is $suffix"
19+
20+
foreach ($src in ls src/*) {
21+
Push-Location $src
22+
23+
echo "build: Packaging project in $src"
24+
25+
if ($suffix) {
26+
& dotnet pack -c Release -o ..\..\artifacts --include-source --version-suffix=$suffix
27+
} else {
28+
& dotnet pack -c Release -o ..\..\artifacts --include-source
29+
}
30+
if($LASTEXITCODE -ne 0) { exit 1 }
31+
32+
Pop-Location
33+
}
34+
35+
foreach ($test in ls test/*.Tests) {
36+
Push-Location $test
37+
38+
echo "build: Testing project in $test"
39+
40+
& dotnet test -c Release
41+
if($LASTEXITCODE -ne 0) { exit 3 }
42+
43+
Pop-Location
44+
}
45+
46+
Pop-Location

README.md

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,67 @@
1-
# NLog.Targets.Seq
1+
# NLog.Targets.Seq [![NuGet Pre Release](https://img.shields.io/nuget/vpre/NLog.Targets.Seq.svg)](https://nuget.org/packages/NLog.Targets.Seq) [![Build status](https://ci.appveyor.com/api/projects/status/o22e6dq0mkftaggc?svg=true)](https://ci.appveyor.com/project/datalust/nlog-targets-seq) [![Join the chat at https://gitter.im/datalust/seq](https://img.shields.io/gitter/room/datalust/seq.svg)](https://gitter.im/datalust/seq)
22

3-
**Work in progress**
3+
An NLog target that writes events to [Seq](https://getseq.net). The target takes full advantage of the structured logging support in **NLog 4.5** to provide hassle-free filtering, searching and analysis.
44

5-
An NLog target that writes events to Seq. Takes advantage of the structured logging support in NLog 4.5; projects targeting earlier NLog versions should install _Seq.Client.NLog_ instead.
5+
Projects using earlier NLog versions require the [_Seq.Client.NLog_ package](https://nuget.org/packages/seq.client.nlog) instead.
6+
7+
### Getting started
8+
9+
After installing NLog, install the _NLog.Targets.Seq_ package from NuGet:
10+
11+
```
12+
Install-Package NLog.Targets.Seq -Pre
13+
```
14+
15+
Then, add the target and rules entries to your NLog configuration:
16+
17+
```xml
18+
<targets async="true">
19+
<target name="seq" xsi:type="Seq" serverUrl="https://localhost:5341" apiKey="" />
20+
</targets>
21+
<rules>
22+
<logger name="*" minlevel="Info" writeTo="seq" />
23+
</rules>
24+
```
25+
26+
Set the `serverUrl` value to the address of your Seq server, and provide an API key if you have one set up.
27+
28+
A complete sample application and _NLog.config_ file can be found [here in this repository](https://github.com/datalust/nlog-targets-seq/tree/dev/sample/Example).
29+
30+
### Structured logging with NLog
31+
32+
NLog 4.5 adds support for [message templates](https://messagetemplates.org), extended format strings that capture first-class properties along with the usual message text.
33+
34+
```csharp
35+
var logger = LogManager.GetCurrentClassLogger();
36+
37+
for (var i = 0; i < 10; ++i)
38+
{
39+
logger.Info("Hello, {Name}, on iteration {Counter}", Environment.UserName, i);
40+
}
41+
```
42+
43+
When the events logged in this snippet are rendered to a file or console, they'll appear just like regular formatted text. In Seq or another structured log data store, you'll see that the original `Name` and `Counter` values are preserved separately:
44+
45+
![EventsInSeq](https://raw.githubusercontent.com/datalust/nlog-targets-seq/dev/asset/nlog-events-in-seq.png)
46+
47+
This makes filtering with expressions such as `Counter > 8` or `Name like 'nb%'` trivial: no regular expressions or log parsing are needed to recover the original values.
48+
49+
The fully-rendered message is there too, so you can still search for text like `"Hello, nblumhardt"` and find the events you'd expect.
50+
51+
### Attaching additional properties
52+
53+
The `target` declaration in _NLog.config_ can be expanded with additional properties:
54+
55+
```xml
56+
<target name="seq" xsi:type="Seq" serverUrl="http://localhost:5341" apiKey="">
57+
<property name="ThreadId" value="${threadid}" as="number" />
58+
<property name="MachineName" value="${machinename}" />
59+
<property name="Source" value="${logger}" />
60+
</target>
61+
```
62+
63+
Any properties specified here will be attached to all outgoing events. You can see examples of `ThreadId` and `MachineName` in the screenshot above. The value can be any supported [layout renderer](https://github.com/NLog/NLog/wiki/Layout-Renderers).
64+
65+
### Acknowledgements
66+
67+
The target is based on the earlier [_Seq.Client.NLog_ project](https://github.com/datalust/seq-client), and benefits from many contributions accepted into that repository.

appveyor.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: '{build}'
2+
skip_tags: true
3+
image: Visual Studio 2017
4+
configuration: Release
5+
install:
6+
- ps: mkdir -Force ".\build\" | Out-Null
7+
- ps: nuget update -Self
8+
build_script:
9+
- ps: ./Build.ps1
10+
test: off
11+
artifacts:
12+
- path: artifacts/NLog.Targets.Seq.*.nupkg
13+
deploy:
14+
- provider: NuGet
15+
api_key:
16+
secure: PyALDQp7P4HGAHww8oSEHAZ3ltQpua2eKKl+3DooOl+tlk5tMmMEW2YQQdhdwH7e
17+
skip_symbols: true
18+
on:
19+
branch: /^(master|dev)$/
20+
- provider: GitHub
21+
auth_token:
22+
secure: hX+cZmW+9BCXy7vyH8myWsYdtQHyzzil9K5yvjJv7dK9XmyrGYYDj/DPzMqsXSjo
23+
artifact: /NLog.Targets.Seq.*\.nupkg/
24+
tag: v$(appveyor_build_version)
25+
on:
26+
branch: master

asset/nlog-events-in-seq.png

126 KB
Loading

asset/nlog-targets-seq.png

3.79 KB
Loading

asset/nlog-targets-seq.snk

596 Bytes
Binary file not shown.

asset/nlog-targets-seq.svg

Lines changed: 103 additions & 0 deletions
Loading

nlog-targets-seq.sln

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.26730.15
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{AC295EEA-D319-4146-97E0-B978DF6F2557}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "global", "global", "{66B005E9-A083-41E8-BD89-4D6E753CD8BF}"
9+
ProjectSection(SolutionItems) = preProject
10+
appveyor.yml = appveyor.yml
11+
Build.ps1 = Build.ps1
12+
LICENSE = LICENSE
13+
README.md = README.md
14+
EndProjectSection
15+
EndProject
16+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{2ED926D3-7AC8-4BFD-A16B-74D942602968}"
17+
EndProject
18+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "asset", "asset", "{69238E6E-26AB-494B-8CBD-65F8C1F0696A}"
19+
ProjectSection(SolutionItems) = preProject
20+
asset\nlog-targets-seq.png = asset\nlog-targets-seq.png
21+
asset\nlog-targets-seq.snk = asset\nlog-targets-seq.snk
22+
asset\nlog-targets-seq.svg = asset\nlog-targets-seq.svg
23+
EndProjectSection
24+
EndProject
25+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{7533E145-1C93-4348-A70D-E68746C5438C}"
26+
EndProject
27+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NLog.Targets.Seq", "src\NLog.Targets.Seq\NLog.Targets.Seq.csproj", "{D4E037DE-9778-4E48-A4A7-E8C1751E637C}"
28+
EndProject
29+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NLog.Targets.Seq.Tests", "test\NLog.Targets.Seq.Tests\NLog.Targets.Seq.Tests.csproj", "{CD473266-4AED-4207-89FD-0B185239F1C7}"
30+
EndProject
31+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example", "sample\Example\Example.csproj", "{34BBD428-8297-484E-B771-0B72C172C264}"
32+
EndProject
33+
Global
34+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
35+
Debug|Any CPU = Debug|Any CPU
36+
Release|Any CPU = Release|Any CPU
37+
EndGlobalSection
38+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
39+
{D4E037DE-9778-4E48-A4A7-E8C1751E637C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40+
{D4E037DE-9778-4E48-A4A7-E8C1751E637C}.Debug|Any CPU.Build.0 = Debug|Any CPU
41+
{D4E037DE-9778-4E48-A4A7-E8C1751E637C}.Release|Any CPU.ActiveCfg = Release|Any CPU
42+
{D4E037DE-9778-4E48-A4A7-E8C1751E637C}.Release|Any CPU.Build.0 = Release|Any CPU
43+
{CD473266-4AED-4207-89FD-0B185239F1C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
44+
{CD473266-4AED-4207-89FD-0B185239F1C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
45+
{CD473266-4AED-4207-89FD-0B185239F1C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
46+
{CD473266-4AED-4207-89FD-0B185239F1C7}.Release|Any CPU.Build.0 = Release|Any CPU
47+
{34BBD428-8297-484E-B771-0B72C172C264}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
48+
{34BBD428-8297-484E-B771-0B72C172C264}.Debug|Any CPU.Build.0 = Debug|Any CPU
49+
{34BBD428-8297-484E-B771-0B72C172C264}.Release|Any CPU.ActiveCfg = Release|Any CPU
50+
{34BBD428-8297-484E-B771-0B72C172C264}.Release|Any CPU.Build.0 = Release|Any CPU
51+
EndGlobalSection
52+
GlobalSection(SolutionProperties) = preSolution
53+
HideSolutionNode = FALSE
54+
EndGlobalSection
55+
GlobalSection(NestedProjects) = preSolution
56+
{D4E037DE-9778-4E48-A4A7-E8C1751E637C} = {AC295EEA-D319-4146-97E0-B978DF6F2557}
57+
{CD473266-4AED-4207-89FD-0B185239F1C7} = {2ED926D3-7AC8-4BFD-A16B-74D942602968}
58+
{34BBD428-8297-484E-B771-0B72C172C264} = {7533E145-1C93-4348-A70D-E68746C5438C}
59+
EndGlobalSection
60+
GlobalSection(ExtensibilityGlobals) = postSolution
61+
SolutionGuid = {DEA01469-166A-4CA9-904E-1D9476D64FFB}
62+
EndGlobalSection
63+
EndGlobal

nlog-targets-seq.sln.DotSettings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=TypeParameters/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb"&gt;&lt;ExtraRule Prefix="" Suffix="" Style="AA_BB" /&gt;&lt;/Policy&gt;</s:String></wpf:ResourceDictionary>

0 commit comments

Comments
 (0)