DevIT Inc. Pakistan
Serving Better
Homepage Company Profile Services Portfolio Clients Feedback Contacts
Design:
Website Design
Website Re-Design
Banned Ad Design
Flash Intros Design
Logo Design
Icon Design
Development:
Website Development
Software Development
Web Applications
eCommerece Solutions
Security Development
Customization
Promotion:
SEO
Link Building
Directory Submission
Article Submission
Administrative Support :
Data Entry
Data Conversion
Word Processing
Image Scaning
Product Management
Mailing List Management
Bulk Mailing

 

Creating A Log File:

Are you interested to know who came to your site? at what time? and what was the referring URL. Here is an example how to make a Log file for an ASP page to keep track of users on your site. With this Log file you will be able to check who visited your site, At what time, What was the reffering URL and what browser that user was using.

This Example use a text file to write user information. If you want to learn more about how to write to a text file within an ASP page Click here.
Create a file LogFile.asp with the following code and add in the header of every page useing Server Side #Include.

<!--#Include File="LogFile.asp"-->

When some one will come to your site on any page which has LogFile.asp included that user's information will be written to LogFile.txt. If the refering url is from same site, LogFile.asp will not write that information.

File: LogFile.asp

<%
Dim blnValidEntry       ' Log variable


' First set that this log is valid blnValidEntry = True
' If Session Variable "LogIn" is not empty ' that mean this person has already been logged ' then set blnValidEntry to False
If not IsEmpty(Session("LogIn")) then blnValidEntry = False
' Here you can add different restriction ' If the refering url is from same site ' then there is no need to write to log file
If Left(Request.ServerVariables("HTTP_REFERER"), 17)="http://devasp.com"  Then  blnValidEntry = False End If
If Left(Request.ServerVariables("HTTP_REFERER"), 21)="http://www.devasp.com"  Then  blnValidEntry = False End If
' Now if blnValidEntry is True then enter to log file
If blnValidEntry  Then  Const ForAppending = 8  Const Create = true  Dim FSO  Dim TS  Dim MyFileName  Dim strLog    MyFileName = Server.MapPath("MyLogFile.txt")
Set FSO = Server.CreateObject("Scripting.FileSystemObject")  Set TS = FSO.OpenTextFile(MyFileName, ForAppending, Create)    ' Store all the required information in a string Called strLog
 strLog = "<br><P><B>" & NOW() & "</B> "  strLog = strLog & Request.ServerVariables("REMOTE_ADDR") & " "  strLog = strLog & Request.ServerVariables("HTTP_REFERER") & " "  strLog = strLog & Request.ServerVariables("HTTP_USER_AGENT") & "<BR>"
 ' Write current information to Log Text File.    TS.write strLog  TS.Writeline ""
 ' Now Create a session varialbe to check next time for ValidEntry
 Session("LogIn") = "yes"  Set TS = Nothing  Set FSO = Nothing End If %>


 

Article Source:
DevIT Inc. is a company specializing in webmasters software development, industrial-strength cloaking and search engine positioning services. He has been a web marketer since 2005. More information available at: http://www.devitpk.com You can contact him at info@devitpk.com (c) Copyright 2007 by DevIT Inc. Pakistan

 


Link Partner: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 .............................................>>>
©Copyright 2007, DevIT Inc. Pakistan