Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/NLogPublic

LogReceiverService target

Rolf Kristensen edited this pageJul 2, 2025 ·15 revisions

Sends log messages to a NLog Receiver Service (using WCF or Web Services).

Platforms Supported:All - Requires nuget-packageNLog.Wcf since NLog 5.0

Configuration Syntax

<targets>  <targetxsi:type="LogReceiverService"name="String"endpointConfigurationName="String"endpointAddress="String"useBinaryEncoding="Boolean"clientId="Layout"includeEventProperties="Boolean">    <parameterlayout="Layout"name="String"type="System.Type"/><!-- repeated-->  </target></targets>

Read more about using theConfiguration File.

Parameters

General Options

  • name - Name of the target.

Connection Options

  • endpointAddress - Endpoint address. Required.

  • endpointConfigurationName - Name of the endpoint configuration in WCF configuration file

    Only supported on .NET Framework platform withapp.config. Trying to enable on .NET Core fails with:System.PlatformNotSupportedException: Configuration files are not supported.

Payload Options

  • useBinaryEncoding - Indicates whether to use binary message encoding.Boolean

  • parameters - The list of parameters.Collection
    Each collection item is represented by <parameter /> element with the following attributes:

    • layout - Layout that should be use to calculate the value for the parameter.Layout Required.
    • name - Name of the parameter.
    • type - Type of the parameter.System.Type
  • clientId - Application Client Identifier, translates intoNLogEvents.ClientNameLayout

  • includeEventProperties - Indicates whether to include per-event properties in the payload sent to the server.Boolean

Examples

Passing Parameters

Parameters are passed to the WCF LogReceiverService target using one or more configuration lines such as:

<parametername="MyParameter"layout="My Value!" /><parametername="nlogdir"layout="${nlogdir}" />

These parameters are passed over the network to the service and can be accessed by emitting events from your receiver application.

Application for receiving events

namespaceMyLogReceiverApp{usingSystem;usingNLog;usingNLog.LogReceiverService;/// <summary>/// Log service server object that logs messages./// </summary>publicclassLogReceiverServer:ILogReceiverServer{publicvoidProcessLogMessages(NLogEventsnevents){varevents=nevents.ToEventInfo("Client.");Console.WriteLine("in: {0} {1}",nevents.Events.Length,events.Count);foreach(varevinevents){varlogger=LogManager.GetLogger(ev.LoggerName);logger.Log(ev);}}}}

-Troubleshooting Guide - See available NLog Targets and Layouts:https://nlog-project.org/config

Configuration

Programmatic Configuration

Advanced

Extending NLog

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp