Somehow differentiating between TRACE and DEBUG levels
Hello, I have a proposal.
I've found myself needing to differentiate between TRACE and DEBUG log leves. I know Syslog considers/maps these two into Severity 7 and since as per the Syslog standard we are locked in a 0-7 range for the severity level, I was thinking...
Could we have this layout print a levelName property so we can differentiate between DEBUG and TRACE coming from NLog without messing around and potentially stepping outside of the Syslog standard? This of course could be set up to be optional and enabled by a configuration parameter just in case this field is not desired in the output.
Is this issue also affecting anyone else, or just me?
I wanted to propose it first, but I can implement this and submit a PR if you'd like.
Proposal
The Syslog log levels Would map as they currently do:
| Log Level | Syslog Mapping |
|---|---|
| Fatal | 2 |
| Error | 3 |
| Warn | 4 |
| Info | 6 |
| Debug | 7 |
| Trace | 7 |
And then we'll have another property added called levelName which will contain the log levels by name.
| Log Level | String in the levelName field |
|---|---|
| Fatal | "Fatal" |
| Error | "Error" |
| Warn | "Warn" |
| Info | "Info" |
| Debug | "Debug" |
| Trace | "Trace" |
You can add your own custom fields like this:
<target xsi:type="Network" name="GelfHttp" address="http://localhost:12201/gelf">
<layout type="GelfLayout">
<field name="threadid" layout="${threadid}" />
<field name="loglevel" layout="${level}" />
</layout>
</target>
See also: https://github.com/NLog/NLog/wiki/Level-Layout-Renderer