Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Somehow differentiating between TRACE and DEBUG levels #33

Open
joanbarros opened this issue Apr 2, 2024 · 1 comment
Open

Somehow differentiating between TRACE and DEBUG levels #33

joanbarros opened this issue Apr 2, 2024 · 1 comment

Comments

@joanbarros
Copy link

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"
@snakefoot
Copy link
Contributor

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants