Class NetSendAppender
Logs entries by sending network messages using the NetMessageBufferSend(string, string, string, string, int) native function.
public class NetSendAppender : AppenderSkeleton, IBulkAppender, IAppender, IOptionHandler
- Inheritance
-
NetSendAppender
- Implements
- Inherited Members
Examples
An example configuration section to log information using this appender from the local machine, named LOCAL_PC, to machine OPERATOR_PC :
Remarks
You can send messages only to names that are active on the network. If you send the message to a user name, that user must be logged on and running the Messenger service to receive the message.
The receiver will get a top most window displaying the messages one at a time, therefore this appender should not be used to deliver a high volume of messages.
The following table lists some possible uses for this appender :
| Action | Property Value(s) |
|---|---|
| Send a message to a user account on the local machine |
Server = <name of the local machine> Recipient = <user name> |
| Send a message to a user account on a remote machine |
Server = <name of the remote machine> Recipient = <user name> |
| Send a message to a domain user account |
Server = <name of a domain controller | uninitialized> Recipient = <user name> |
| Send a message to all the names in a workgroup or domain |
Recipient = <workgroup name | domain name>* |
| Send a message from the local machine to a remote machine |
Server = <name of the local machine | uninitialized> Recipient = <name of the remote machine> |
Note : security restrictions apply for sending network messages, see NetMessageBufferSend(string, string, string, string, int) for more information.
Constructors
NetSendAppender()
Initializes the appender.
public NetSendAppender()
Remarks
The default constructor initializes all fields to their default values.
Properties
Recipient
Gets or sets the message alias to which the message should be sent.
public string Recipient { get; set; }
Property Value
- string
The recipient of the message.
Remarks
This property should always be specified in order to send a message.
RequiresLayout
This appender requires a log4net.Layout to be set.
protected override bool RequiresLayout { get; }
Property Value
- bool
true
Remarks
This appender requires a log4net.Layout to be set.
SecurityContext
Gets or sets the SecurityContext used to call the NetSend method.
public SecurityContext SecurityContext { get; set; }
Property Value
- SecurityContext
The SecurityContext used to call the NetSend method.
Remarks
Unless a SecurityContext specified here for this appender the DefaultProvider is queried for the security context to use. The default behavior is to use the security context of the current thread.
Sender
Gets or sets the sender of the message.
public string Sender { get; set; }
Property Value
- string
The sender of the message.
Remarks
If this property is not specified, the message is sent from the local computer.
Server
Gets or sets the DNS or NetBIOS name of the remote server on which the function is to execute.
public string Server { get; set; }
Property Value
- string
DNS or NetBIOS name of the remote server on which the function is to execute.
Remarks
For Windows NT 4.0 and earlier, the string should begin with \\.
If this property is not specified, the local computer is used.
Methods
ActivateOptions()
Initialize the appender based on the options set.
public override void ActivateOptions()
Remarks
This is part of the IOptionHandler delayed object activation scheme. The ActivateOptions() method must be called on this object after the configuration properties have been set. Until ActivateOptions() is called this object is in an undefined state and must not be used.
If any of the configuration properties are modified then ActivateOptions() must be called again.
The appender will be ignored if no Recipient was specified.
Exceptions
- ArgumentNullException
The required property Recipient was not specified.
Append(LoggingEvent)
This method is called by the AppenderSkeleton.DoAppend(LoggingEvent) method.
protected override void Append(LoggingEvent loggingEvent)
Parameters
loggingEventLoggingEventThe event to log.
Remarks
Sends the event using a network message.
NetMessageBufferSend(string, string, string, string, int)
Sends a buffer of information to a registered message alias.
protected static extern int NetMessageBufferSend(string serverName, string msgName, string fromName, string buffer, int bufferSize)
Parameters
serverNamestringThe DNS or NetBIOS name of the server on which the function is to execute.
msgNamestringThe message alias to which the message buffer should be sent
fromNamestringThe originator of the message.
bufferstringThe message text.
bufferSizeintThe length, in bytes, of the message text.
Returns
- int
If the function succeeds, the return value is zero.
Remarks
The following restrictions apply for sending network messages:
| Platform | Requirements |
|---|---|
| Windows NT |
No special group membership is required to send a network message. Admin, Accounts, Print, or Server Operator group membership is required to successfully send a network message on a remote server. |
| Windows 2000 or later |
If you send a message on a domain controller that is running Active Directory, access is allowed or denied based on the access control list (ACL) for the securable object. The default ACL permits only Domain Admins and Account Operators to send a network message. On a member server or workstation, only Administrators and Server Operators can send a network message. |
For more information see Security Requirements for the Network Management Functions.