Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Build String and Log It

Status
Not open for further replies.

jowsley

Programmer
Jul 18, 2003
3
0
0
US
I'm looking to build a string using values set in an object. The string will be the xml representation of the object. Once I have built the string, I would like to write it to the log file and with certain values (like passwords) masked out with "*". The question I have is how do I do this in a way that is reasonable performance conscious? I see two main options:

1. Build two strings from the object (one for logging and one for the application) so that the loggable string can simply be written to the log.

2. Build the string to be used by the application and then search for the fields that I want to mask and build the loggable string.

 
I worked on an application that did about the same thing you described; we build a string like this to pass to the interface:
strXML=&quot;<value1>&quot; & object.value1 & &quot;</value1>&quot; etc etc.
Performance is lousy when you have a reasonable amount of data. At least try and concatenate as little as possible in VB.
For example: use ADO to get XML from a recordset, use DOM to create xml from variables.
Do not build two strings, but put the string in a domdocument.
for each Nde in objDOM.selectnodes(&quot;//password&quot;)
nde.text=&quot;***&quot;
next
objDOM.save &quot;c:/whatever&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top