Aaron, 

> The FAQ gives examples of using %P{hostname} and %W for the 
> username. The hostname property was always blank and the 
> usename property always returned the user owning the local 
> logging process not the one the user of the one that 
> generated the logging message.
> 
> After looking in the coded I got the hostname working 
> correctly by using %P{log4net:HostName}. I am not sure if 
> this is by design and the FAQ is incorrect or there is 
> something I have missed?

%P{log4net:HostName} is the correct syntax for retrieving the hostname
property stored by the RemotingAppender.
I will investigate the error in the documentation.


> To fix the username problem I changed the SendBuffer method 
> of the RemotingAppender class as shown below and then used 
> %P{log4net:UserName}. Once again not sure if this is needed 
> or I have missed something?

The RemotingAppender will capture and send the UserName with the event only
if instructed to do so. The generation of the WindowsIdentity object to
capture the UserName is an expensive call. 

The example Remoting Client App.config specifies the following:

<!-- Do not store event data that is slow to generate -->
<param name="OnlyFixPartialEventData" value="true" />

This setting cases the RemotingAppender to not capture the UserName,
Identity, and LoactionInfo. To capture all the event values you can use the
Fix parameter rather than the OnlyFixPartialEventData, for example:

<param name="Fix"
value="Mdc,Ndc,Message,ThreadName,Exception,Domain,LocationInfo,UserName,Ide
ntity" />

There are two shorthand values:

All ==
Mdc,Ndc,Message,ThreadName,Exception,Domain,LocationInfo,UserName,Identity

Partial == Mdc,Ndc,Message,ThreadName,Exception,Domain

If you just want to add the UserName to what is already captured you can
use:
<param name="Fix" value="Partial,UserName" />


Cheers,
Nicko

Reply via email to