A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/NLog/NLog/wiki/Properties-constraints-for-custom-extensions below:

Properties constraints for custom extensions · NLog/NLog Wiki · GitHub

Custom Targets, layout etc. could have properties. When configuring from the XML config, there are some limitations on the types.

Supported types for Targets, Layouts and Layout renderers:

Introduced in NLog 4.4, collection types could be used.

Usage in XML: comma separated string. If the value contains a comma, single quote the whole value.

Examples:

Supported types:

with the following types:

Not supported:

PS: .NET 3.5 hasn't ISet<T>, so use HashSet<T>

For targets and layout renderers there is also support for XML elements.

E.g. the JSON layout:

<target name="jsonFile" xsi:type="File" fileName="${logFileNamePrefix}.json">
      <layout xsi:type="JsonLayout">
              <attribute name="time" layout="${longdate}" />
              <attribute name="level" layout="${level:upperCase=true}"/>
              <attribute name="message" layout="${message}" />
       </layout>
</target>

Usage in C#

[ArrayParameter(typeof(JsonAttribute), "attribute")]
public IList<JsonAttribute> Attributes { get; private set; }

[NLogConfigurationItem]
public class JsonAttribute {} //needs default ctor

Another example is the Database target


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4