Giter VIP home page Giter VIP logo

nlog.gelflayout's People

Contributors

304notmodified avatar farzadpanahi avatar reifl avatar snakefoot avatar tomikiss avatar unoparator avatar vitaliitsilnyk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nlog.gelflayout's Issues

Truncated messages

Can make message length FullMessageMaxLength and ShortMessageMaxLength configurable?
not hardcoded

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"

How use variables in nlog.config for reuse layout

Hi, how use variables in nlog.config for reuse layout ?

	<?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">
	<extensions>
		<add assembly="NLog.Web.AspNetCore" />
		<add assembly="NLog.Layouts.GelfLayout" />
	</extensions>

	<variable name="UdpElkEndpointUrl" value="udp://ip:12201"/>

	<variable name='GelfMinimalLayout'>
		<layout type='GelfLayout'>
			<field name="lang" layout="dotnet" />
			<field name="source" layout="${moduleNameForGelfSource}" />
			<field name="facility" layout="${aspnet-environment}" />
			<field name="UserName" layout="${username}"/>
			<field name="longdate" layout="${longdate}" />
			<field name="exception" layout="${exception:format=tostring}" />
			<field name="stacktrace" layout="${stacktrace}" />
			<field name="message" layout="${message}" />
		</layout>
	</variable>
	
	<targets async="true">
		<target xsi:type="Network" name="gelfUdp" address="${UdpElkEndpointUrl}" compress="GZip" compressMinBytes="1000">
			<layout type="GelfLayout">
				<layout type='${GelfMinimalLayout}' />
				<field name="appdomain" layout="${appdomain}" />
				<field name="environmentUser" layout="${environment-user}" />
				<field name="machinename" layout="${machinename}" />
				<field name="iisSiteName" layout="${iis-site-name}" />
				<field name="windowsUser" layout="${windowsUser}" />
				<field name="localIp" layout="${local-ip}" />
				<field name="clientIpAddr" layout="${clientIpAddr}" />
				<field name="requestIp" layout="${aspnet-request-ip}" />
				<field name="requestUseragent" layout="${aspnet-request-useragent}" />
				<field name="requestMethod" layout="${aspnet-request-method}" />
				<field name="requestUrl" layout="${aspnet-request-url:IncludeHost=true:IncludePort=true:IncludeQueryString=true}" />
			</layout>
	                <!--<layout type="${GelfMinimalLayout}">
	                        <field name="appdomain" layout="${appdomain}" />
	                        <field name="environmentUser" layout="${environment-user}" />
	                        <field name="machinename" layout="${machinename}" />
	                        <field name="iisSiteName" layout="${iis-site-name}" />
	                        <field name="windowsUser" layout="${windowsUser}" />
	                        <field name="localIp" layout="${local-ip}" />
	                        <field name="clientIpAddr" layout="${clientIpAddr}" />
	                        <field name="requestIp" layout="${aspnet-request-ip}" />
	                        <field name="requestUseragent" layout="${aspnet-request-useragent}" />
	                        <field name="requestMethod" layout="${aspnet-request-method}" />
	                        <field name="requestUrl" layout="${aspnet-request-url:IncludeHost=true:IncludePort=true:IncludeQueryString=true}" />
                         </layout>-->
		</target>
	```

did not work

Can't add extra fields like a example in readme

Hello,

In my project if i make this ( https://github.com/farzadpanahi/NLog.GelfLayout#sample-usage-with-custom-extra-fields ) example without extra fields, the Gelf Log works good!
But if I add extra fields, like this example ( https://github.com/farzadpanahi/NLog.GelfLayout#sample-usage-with-custom-extra-fields ), the program sends an error in runtime "Layout cannot be found: 'GelfLayout'"

Error details:
NLog.NLogConfigurationException
HResult=0x80131500
Message=Exception when parsing
(...)
ArgumentException: Layout cannot be found: 'GelfLayout'

Gelf severity level mapping

Not sure if the NLog-Ordinal-Level-Numbers match Syslog-Severity-Numbers:

Level = logEventInfo.Level.GetOrdinal(),

This is one source of Syslog-Severity-Numbers:

http://logging.paluch.biz/syslog-level-mapping.html

Level NLog Ordinal SysLog Severity
Trace 0 7
Debug 1 6
Info 2 6
Warning 3 4
Error 4 3
Fatal 5 2

Right now Info-Level-messages from NLog will become fatal-syslog-loglevel-messages.

@tomikiss I can make a PR for fixing this. If it makes sense?

Layout ends up emtpy when using a Nlog Target Wrapper with GelfLayout

We are having some issues when combining Nlog.GelfLayout with a Nlog Target wrapper like RandomizeGroup (https://github.com/NLog/NLog/wiki/RandomizeGroup-target) or RoundRobinGroup (https://github.com/NLog/NLog/wiki/RoundRobinGroup-target)

The entire Gelf message is missing from the output.

Example working config without wrapper:

<?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:haf="https://github.com/haf/NLog.RabbitMQ/raw/master/src/schemas/NLog.RabbitMQ.xsd"
      xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
      autoReload="true"
      throwExceptions="false"
      internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log" >

      <extensions>
      <add assembly="NLog.Targets.RabbitMQ" />
      <add assembly="NLog.Layouts.GelfLayout" />
    </extensions>

    <targets async="true">
    <target name="RabbitMQTarget"
            xsi:type="RabbitMQ"
            hostname="x"
            username="x"
            password="x"
            exchange="amq.direct"
            topic="x"
            passive="true"
            vhost="nif-graylog"
            durable="true"
            useJSON="false"
            layout="${gelf:facility=GelfLog}"
    />
  </targets>

  <rules>
    <logger name="*" minlevel="Trace" writeTo="RabbitMQTarget" />
  </rules>
</nlog>

Example non-working config with wrapper:

<?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:haf="https://github.com/haf/NLog.RabbitMQ/raw/master/src/schemas/NLog.RabbitMQ.xsd"
      xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
      autoReload="true"
      throwExceptions="false"
      internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log" >

    <extensions>
      <add assembly="NLog.Targets.RabbitMQ" />
      <add assembly="NLog.Layouts.GelfLayout" />
    </extensions>

    <targets async="true">
    <target name="RabbitMQTarget" xsi:type="RandomizeGroup">
      <target xsi:type="RabbitMQ"
              hostname="x"
              username="x"
              password="x"
              exchange="amq.direct"
              topic="x"
              passive="true"
              vhost="x"
              durable="true"
              useJSON="false"
              layout="${gelf:_facility=GelfLog}" />
      <target xsi:type="RabbitMQ"
              hostname="x2"
              username="x"
              password="x"
              exchange="amq.direct"
              topic="x"
              passive="true"
              vhost="x"
              durable="true"
              useJSON="false"
              layout="${gelf:facility=GelfLog}" />
    </target>
  </targets>

  <rules>
    <logger name="*" minlevel="Trace" writeTo="RabbitMQTarget" />
  </rules>
</nlog>

Any idea how to solve this?

When specifying a field with the name source and layout different from the lowercase word, udp gelf does not work

When specifying a field with the name source and layout different from the lowercase word, udp gelf does not work
This is how it works

<field name="source" layout="producersrequestswebapicore" />

or

<field name="source" layout="producers-requests-web-api-core" />

or

<field name="source" layout="producers_requests_web_api_core" />

But no

<field name="source" layout="producersRequestsWebApiCore" />

or

<field name="source" layout="ProducersRequestsWebApiCore" />

asp core 3.1 web api
NLog.GelfLayout 1.4.0

....probably because source is used in index in elk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.