473,386 Members | 1,609 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Best way to write log file

Hi, I'm developing a site statistics application, now it's in testing and I
get a very high CPU usage on the aspnet_wp.exe, I think it's because the way
I'm writing the log file, I'm using XML to do it, Which is the best way to
do it, I'm including a portion of the code so you can see what I'm doing...

Dim objXmlDoc As New XmlDataDocument
objXmlDoc.Load(strLogFullPath)

Dim root As XmlNode = objXmlDoc.DocumentElement

Dim LastNode As XmlNode = root.LastChild
Dim strLId As String

If LastNode Is Nothing Then
strLId = "1"
Else
strLId = LastNode.Item("Id").InnerText + 1
End If

Dim PageView As XmlElement =
objXmlDoc.CreateElement("PageView")

Dim Id As XmlElement = objXmlDoc.CreateElement("Id")
Dim SiteId As XmlElement = objXmlDoc.CreateElement("SiteId")
Dim PageViewDate As XmlElement =
objXmlDoc.CreateElement("PageViewDate")
Dim SessionId As XmlElement =
objXmlDoc.CreateElement("SessionId")
Dim CookieId As XmlElement =
objXmlDoc.CreateElement("CookieId")
Dim PageName As XmlElement =
objXmlDoc.CreateElement("PageName")
Dim Referral As XmlElement =
objXmlDoc.CreateElement("Referral")
Dim IP As XmlElement = objXmlDoc.CreateElement("IP")
Dim Browser As XmlElement =
objXmlDoc.CreateElement("Browser")
Dim Screen As XmlElement = objXmlDoc.CreateElement("Screen")
Dim UserAgent As XmlElement =
objXmlDoc.CreateElement("UserAgent")
Dim CountryCode As XmlElement =
objXmlDoc.CreateElement("CountryCode")
Dim TimeZone As XmlElement =
objXmlDoc.CreateElement("TimeZone")

Id.InnerText = CType(strLId, String)
SiteId.InnerText = CType(intSiteId, String)
PageViewDate.InnerText = CType(dtmDateTime, String)
SessionId.InnerText = CType(intSessionId, String)
CookieId.InnerText = CType(intCookieId, String)
PageName.InnerText = strPageName
Referral.InnerText = strReferral
IP.InnerText = strIP
Browser.InnerText = strBrowser
Screen.InnerText = strScreen
UserAgent.InnerText = strUserAgent
CountryCode.InnerText = strCountryCode
TimeZone.InnerText = CType(intTimeZone, String)

PageView.AppendChild(Id)
PageView.AppendChild(SiteId)
PageView.AppendChild(PageViewDate)
PageView.AppendChild(SessionId)
PageView.AppendChild(CookieId)
PageView.AppendChild(PageName)
PageView.AppendChild(Referral)
PageView.AppendChild(IP)
PageView.AppendChild(Browser)
PageView.AppendChild(Screen)
PageView.AppendChild(UserAgent)
PageView.AppendChild(CountryCode)
PageView.AppendChild(TimeZone)

root.AppendChild(PageView)

objXmlDoc.Save(strLogFullPath)

Any help is greatly appreciated, thank you.

pa***@imaget.com

Nov 18 '05 #1
2 3225
use an xmlwriter instead of the dom.

-- bruce (sqlwork.com)
"Pablo Tola" <pablo[remove]@imaget.com> wrote in message
news:OO**************@TK2MSFTNGP11.phx.gbl...
Hi, I'm developing a site statistics application, now it's in testing and I get a very high CPU usage on the aspnet_wp.exe, I think it's because the way I'm writing the log file, I'm using XML to do it, Which is the best way to
do it, I'm including a portion of the code so you can see what I'm doing...
Dim objXmlDoc As New XmlDataDocument
objXmlDoc.Load(strLogFullPath)

Dim root As XmlNode = objXmlDoc.DocumentElement

Dim LastNode As XmlNode = root.LastChild
Dim strLId As String

If LastNode Is Nothing Then
strLId = "1"
Else
strLId = LastNode.Item("Id").InnerText + 1
End If

Dim PageView As XmlElement =
objXmlDoc.CreateElement("PageView")

Dim Id As XmlElement = objXmlDoc.CreateElement("Id")
Dim SiteId As XmlElement = objXmlDoc.CreateElement("SiteId") Dim PageViewDate As XmlElement =
objXmlDoc.CreateElement("PageViewDate")
Dim SessionId As XmlElement =
objXmlDoc.CreateElement("SessionId")
Dim CookieId As XmlElement =
objXmlDoc.CreateElement("CookieId")
Dim PageName As XmlElement =
objXmlDoc.CreateElement("PageName")
Dim Referral As XmlElement =
objXmlDoc.CreateElement("Referral")
Dim IP As XmlElement = objXmlDoc.CreateElement("IP")
Dim Browser As XmlElement =
objXmlDoc.CreateElement("Browser")
Dim Screen As XmlElement = objXmlDoc.CreateElement("Screen") Dim UserAgent As XmlElement =
objXmlDoc.CreateElement("UserAgent")
Dim CountryCode As XmlElement =
objXmlDoc.CreateElement("CountryCode")
Dim TimeZone As XmlElement =
objXmlDoc.CreateElement("TimeZone")

Id.InnerText = CType(strLId, String)
SiteId.InnerText = CType(intSiteId, String)
PageViewDate.InnerText = CType(dtmDateTime, String)
SessionId.InnerText = CType(intSessionId, String)
CookieId.InnerText = CType(intCookieId, String)
PageName.InnerText = strPageName
Referral.InnerText = strReferral
IP.InnerText = strIP
Browser.InnerText = strBrowser
Screen.InnerText = strScreen
UserAgent.InnerText = strUserAgent
CountryCode.InnerText = strCountryCode
TimeZone.InnerText = CType(intTimeZone, String)

PageView.AppendChild(Id)
PageView.AppendChild(SiteId)
PageView.AppendChild(PageViewDate)
PageView.AppendChild(SessionId)
PageView.AppendChild(CookieId)
PageView.AppendChild(PageName)
PageView.AppendChild(Referral)
PageView.AppendChild(IP)
PageView.AppendChild(Browser)
PageView.AppendChild(Screen)
PageView.AppendChild(UserAgent)
PageView.AppendChild(CountryCode)
PageView.AppendChild(TimeZone)

root.AppendChild(PageView)

objXmlDoc.Save(strLogFullPath)

Any help is greatly appreciated, thank you.

pa***@imaget.com

Nov 18 '05 #2
You can create a Log object, ie LogValue that has the properties PageViewDate, SiteId, CookieId, etc. ... you then set the properties of the object just like you would any other object. You can then use XML serialization to serialize the object to a stream and write it out. It will be much more efficient than building the XML file by hand.
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
1
by: Herve MAILLARD | last post by:
Hi, I have to write a software doing the following : - Load a file (containing data) Data will be display in a Treeview and are typed as following Equipement Bloc Tag It could have for each...
7
by: Jimbo | last post by:
What's the best format to save a configuration file? I'm currently using an INI extension and I write it like a normal ascii file. Is this the best way? I've heard of using XML to create a config...
12
by: Nettan | last post by:
Hi What is the best way to write to a textfile, is it with FileSystemObject or with StreamWriter? Thanks /Nettan
3
by: gordon | last post by:
Hi I am looking to store some details about a user's configuration choices, in particular the place where they have installed some data files, the OS that they use, and their Windows user name. ...
3
by: Nemisis | last post by:
Guys, I would like to write a error handler, or something, that will allow me to write to a database when an error occurs on my site. I am trying to implement this in the global.asax file a the...
9
by: Brian Cryer | last post by:
I've developed software (vb.net) that renders maps using svg. My manager would like this "mapping component" to be migrated into a library so it can easily be used by other web based applications....
6
by: kamsmartx | last post by:
I'm new to programming and need some help figuring out an algorithm. I need to design some kind of algorithm which will help us define capacity for one of our portfolios....here's the problem...
2
by: hotflash | last post by:
Hi All, I found the best pure ASP code to upload a file to either server and/or MS Access Database. It works fine for me however, there is one thing that I don't like and have tried to fix but...
10
by: Brendan Miller | last post by:
What would heavy python unit testers say is the best framework? I've seen a few mentions that maybe the built in unittest framework isn't that great. I've heard a couple of good things about...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.