Skip to content

Commit 6c65355

Browse files
committed
NLog v6 - Preview1 (Syslog and Gelf examples)
1 parent 0f3de41 commit 6c65355

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

_posts/2025-04-29-nlog-6-0-major-changes.md

+54
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,31 @@ The `GelfTarget` extends the standard `NetworkTarget` with the new `GelfLayout`.
138138
It depends on the builtin NLog JSON serializer, but follows the 'standard' of prefixing all
139139
custom property-names with underscore `_`.
140140

141+
```xml
142+
<nlog>
143+
<extensions>
144+
<add assembly="NLog.Targets.Network" />
145+
</extensions>
146+
147+
<targets async="true">
148+
<target xsi:type="Gelf" name="GelfTcp" address="tcp://localhost:12200" newLine="true" lineEnding="Null">
149+
<GelfField name="MyPropertyName" layout="MyPropertyValue" />
150+
</target>
151+
</targets>
152+
153+
<rules>
154+
<logger name="*" minlevel="Debug" writeTo="GelfTcp" />
155+
</rules>
156+
</nlog>
157+
```
158+
159+
Available `GelfTarget`-options that can be adjusted:
160+
- GelfHostName
161+
- GelfShortMessage
162+
- GelfFullMessage
163+
- IncludeEventProperties
164+
- IncludeScopeProperties
165+
141166
### NLog SyslogTarget and SyslogLayout
142167

143168
The [NLog.Targets.Network](https://www.nuget.org/packages/NLog.Targets.Network) nuget-package also includes support for the Syslog Output Format.
@@ -146,6 +171,35 @@ The `SyslogTarget` extends the standard `NetworkTarget` with the new `SyslogLayo
146171

147172
The `SyslogLayout` supports both RFC-3164 (simple) + RFC-5424 (structured) logging output.
148173

174+
```xml
175+
<nlog>
176+
<extensions>
177+
<add assembly="NLog.Targets.Network" />
178+
</extensions>
179+
180+
<targets async="true">
181+
<target xsi:type="SysLog" name="SyslogTcp" address="tcp://localhost:514">
182+
<Rfc3164>false</Rfc3164>
183+
<Rfc5424>true</Rfc5424>
184+
<StructuredDataParam name="MyPropertyName" layout="MyPropertyValue" />
185+
</target>
186+
</targets>
187+
188+
<rules>
189+
<logger name="*" minlevel="Debug" writeTo="SyslogTcp" />
190+
</rules>
191+
</nlog>
192+
```
193+
194+
Available `SyslogLayout`-options that can be adjusted:
195+
- SyslogAppName
196+
- SyslogHostName
197+
- SyslogMessage
198+
- SyslogLevel
199+
- SyslogFacility
200+
- StructuredDataId
201+
- IncludeEventProperties
202+
149203
### NLog NetworkTarget with NoDelay = true
150204

151205
The [NLog.Targets.Network](https://www.nuget.org/packages/NLog.Targets.Network) nuget-package includes support for configuring TCP_NODELAY.

0 commit comments

Comments
 (0)