Comments (3)
I ended up doing this:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sl="http://www.nlog-project.org/schemas/NLog.Targets.Syslog.xsd" throwExceptions="true">
<targets>
<target xsi:type="ColoredConsole" name="console">
<layout xsi:type="SimpleLayout" text="${message}${exception:format=ToString,StackTrace}" />
</target>
<target xsi:type="sl:Syslog" name="syslog">
<sl:layout xsi:type="SimpleLayout" text="${message}${exception:format=ToString,StackTrace}" />
<sl:enforcement>
<sl:splitOnNewLine>false</sl:splitOnNewLine>
<sl:transliterate>false</sl:transliterate>
<sl:replaceInvalidCharacters>false</sl:replaceInvalidCharacters>
<sl:truncateFieldsToMaxLength>true</sl:truncateFieldsToMaxLength>
<sl:truncateMessageTo>1024</sl:truncateMessageTo>
</sl:enforcement>
<sl:messageCreation>
<sl:facility>Local4</sl:facility>
<sl:rfc>rfc5424</sl:rfc>
<sl:rfc5424>
<sl:hostname xsi:type="SimpleLayout" text="${machinename}" />
<sl:appName xsi:type="SimpleLayout" text="${processname}" />
<sl:procId xsi:type="SimpleLayout" text="${processid}" />
<sl:msgId xsi:type="SimpleLayout" text="${threadid}" />
<sl:structuredData>
<sl:fromEventProperties xsi:type="SimpleLayout" text="[app@0 ${all-event-properties:format=[key]="[value]":separator= :includeCallerInformation=False}]" />
</sl:structuredData>
</sl:rfc5424>
</sl:messageCreation>
<sl:messageSend>
<sl:protocol>UDP</sl:protocol>
<sl:udp>
<sl:server>syslogserver</sl:server>
<sl:port>514</sl:port>
</sl:udp>
</sl:messageSend>
</target>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="console" />
<logger name="*" minlevel="Debug" writeTo="syslog" />
</rules>
</nlog>
It seems a little bit hacky because I'm building the structured data string from scratch in the layout, but it does work. I think it would probably break if any of my properties included a quote (") or brackets.
Thanks!
-Z
from nlog.targets.syslog.
I think I misunderstood how this is supposed to work. I'm closing this out.
from nlog.targets.syslog.
Take a look at:
- https://github.com/NLog/NLog/wiki/EventProperties-Layout-Renderer
- https://github.com/graffen/NLog.Targets.Syslog/blob/3ae37f0c21170617f8c2071536f54a6d5d84d47b/src/TestApp/NLog.config#L59
- https://github.com/graffen/NLog.Targets.Syslog/blob/54c28889aaebbdf1ca7ce3689b55034dd80a8217/src/NLog.Targets.Syslog/MessageCreation/StructuredData.cs#L27
from nlog.targets.syslog.
Related Issues (20)
- The community profile is incomplete
- NuGet API key expired
- Name of wrapped target has "_wrapped" suffix HOT 3
- Infinite retries and potential log entries lost upon delivery failure HOT 2
- Delivery issues result in infinite retries HOT 1
- Delivery issues can result in lost log entries HOT 4
- UnobservedTaskException thrown on configuration reload HOT 3
- Superfluous catch of OperationCanceledException
- Support for .NET Framework not needed
- Multiple build services are used
- How to get started is missing HOT 1
- Extensions section missing in sample configuration HOT 1
- NLog version in README is wrong
- Build badges in README are not relevant
- NuGet publication fails with Powershell error
- NuGet publication unable to find packages
- Is the target compatible with the new NLog extension configuration? HOT 32
- Improper dependency handling with .NET Framework application HOT 5
- structured logging - Escaping special characters for ${all-event-properties} layout renderer HOT 1
- Syslog logging just randomly stops HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nlog.targets.syslog.