Is it possible to change MachineName for LogEntry

Topics: Logging Application Block
Jul 30, 2010 at 10:31 PM

I am trying to log an entry coming from a remote computer, so before logging I need to change MachineName for the log entry to that of remote computer. I tried setting MachineName property of LogEntry object to the remote computer's machine name, but in event log I still see machinename of server where logging is running. Any idea how to change machinename that goes into event log?

 

Thanks

Aug 2, 2010 at 1:20 AM
Edited Aug 2, 2010 at 1:21 AM

The MachineName info is populated using Environment.MachineName.  A workaround would be to add an item in a logEntry's ExtendedProperties collection which would contain the machine name you want.  Sample code:

logEntry.ExtendedProperties.Add("machineName", webServerMachineName);

Modify your trace listener's text formatter template to remove the {localMachine} token and replace it with the token for the machineName you added in the ExtendedProperties collection:

{keyValue(machineName)}

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Aug 2, 2010 at 11:59 PM

Thanks Sarah. That worked.