473,385 Members | 1,326 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,385 software developers and data experts.

OpenTextFile and logging

JT
i have a text file that is used as a logfile for easier debugging. i am
using the OpenTextFile method to write to this file. this method exists
inside a logging function that can be called from anywhere in my ASP. this
works great for our development system b/c we have a limited number of
users.

however, we're unable to use this logging mechanism on live due to
concurrency issues. when two users attempt to open and write to the text
file at the same time, we have problems.

i thought the easiest way around this would be to first check if the text
file is already open - if it is, then send the user into a loop until the
file is available. however, i don't know of a method to check whether a
text file is in use. any suggestions? or any other ways i might get around
this concurrency issue?

thanks much
Jul 19 '05 #1
6 3769
If you're going to be logging a lot of stuff, I suggest doing so into a
database then so you don't have to worry about concurrent usage issues.
Another option is to shell out and pipe your log entry in. This will not
solve the problem, but it's faster (at least for the file operation part)
and should at least avoid errors.

Sub LogSomething(memo)
Const FILE_PATH = "D:Path\On\Server\file.txt"
Set oShell = Server.CreateObject("WScript.Shell")
oShell.Run "cmd.exe /c echo " & memo & ">>" & FILE_PATH
Set oShell = Nothing
End Sub

Ray at work

"JT" <je******@sppinc.net> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
i have a text file that is used as a logfile for easier debugging. i am
using the OpenTextFile method to write to this file. this method exists
inside a logging function that can be called from anywhere in my ASP. this works great for our development system b/c we have a limited number of
users.

however, we're unable to use this logging mechanism on live due to
concurrency issues. when two users attempt to open and write to the text
file at the same time, we have problems.

i thought the easiest way around this would be to first check if the text
file is already open - if it is, then send the user into a loop until the
file is available. however, i don't know of a method to check whether a
text file is in use. any suggestions? or any other ways i might get around this concurrency issue?

thanks much

Jul 19 '05 #2
An old trick is to create an empty dummy file everytime you open your text
file, and delete it when finished writing to your text file. Then, your
program can just check for the existence of this file. If it exists, the
text file is open.

Of course, a much better solution would be to write your debug info into a
table in an Access database. Probably takes less code than writing to a
text file, in my opinion.
"JT" <je******@sppinc.net> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
i have a text file that is used as a logfile for easier debugging. i am
using the OpenTextFile method to write to this file. this method exists
inside a logging function that can be called from anywhere in my ASP. this works great for our development system b/c we have a limited number of
users.

however, we're unable to use this logging mechanism on live due to
concurrency issues. when two users attempt to open and write to the text
file at the same time, we have problems.

i thought the easiest way around this would be to first check if the text
file is already open - if it is, then send the user into a loop until the
file is available. however, i don't know of a method to check whether a
text file is in use. any suggestions? or any other ways i might get around this concurrency issue?

thanks much

Jul 19 '05 #3
> i have a text file that is used as a logfile for easier debugging.

Easier than what? What are you comparing to?

I use a database for logging. Text files have the potential to get huge and
completely unmanageable, and are very prone to concurrency issues. With the
right database, you shouldn't see this problem at all, and I can't see how
debugging would be more difficult. In fact, it would be easier... you can
write queries with where clauses instead of doing a brute force find in a
big text file (or worse, a collection of text files).
Jul 19 '05 #4
JT
> Easier than what? What are you comparing to?

uhhh - easier than nothing at all

????

i will definitely stop with the text file logging and use my database - not
sure why i didn't think of that before.

thanks all for the advice.

"Foo Man Chew" <fo*@man.chew> wrote in message
news:uA**************@TK2MSFTNGP12.phx.gbl...
i have a text file that is used as a logfile for easier debugging.
Easier than what? What are you comparing to?

I use a database for logging. Text files have the potential to get huge

and completely unmanageable, and are very prone to concurrency issues. With the right database, you shouldn't see this problem at all, and I can't see how
debugging would be more difficult. In fact, it would be easier... you can
write queries with where clauses instead of doing a brute force find in a
big text file (or worse, a collection of text files).

Jul 19 '05 #5
> > Easier than what? What are you comparing to?

uhhh - easier than nothing at all

????


Oh, then you meant "easy" debugging. The word "easier" implies that you
were using text files to make debugging less complex than some other
unmentioned method.
Jul 19 '05 #6
danjam
7
Why re-invent the wheel? There are tried and tested logging applications that'll do the job and allow you to adapt as your requirements change.

For example: log4net (the .NET version of Java's log4j).

Here's an introduction to log4net with ASP .NET:

log4net article
http://www.webonweboff.com/tips/asp/logging.aspx

Hope this helps

Daniel
Jul 6 '06 #7

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

Similar topics

1
by: jjesso | last post by:
I am trying to add a new logging level. logging.config.fileConfig("bengineLog.cfg") logging.CLIENT = logging.INFO + 1 logging.addLevelName( logging.CLIENT, 'CLIENT' ) logging.root.setLevel( )...
2
by: jwallison | last post by:
XPSp1/IIS 5.1 What am I doing wrong? The following code just hangs in asp page at OpenTextFile() - and inet service manager just hangs if I try to unload app at this point - <script...
3
by: Fie Fie Niles | last post by:
In my ASP (IIS 5.1), when I use oFile.OpenTextFile to open a file, the code stucks. How can I fix this problem? Thanks. set oFile = CreateObject("Scripting.FileSystemObject") strServerFileName...
0
by: Simon K | last post by:
I'm trying to write a .txt file with OpenTextFile method. This is working alright, but since I'm using some danish characters and use Flash to read the txt file I need to save the file as UTF-8 or...
2
by: Serge Myrand | last post by:
Hi, I cannot use the OpenTextFile method, it's never return and I get no error message! Setting Response.Buffer=False, has no effect. No matter if I use it ForReading or ForWriting, it never...
0
by: Karuppasamy | last post by:
H I am trying to use the Logging Module provided by Microsoft Application Blocks for .Net I installed everything as per the Instructions given in the 'Development Using the Logging Block' ...
6
by: pmatos | last post by:
Hi all, I am trying to create a simple but efficient C++ logging class. I know there are lots of them out there but I want something simple and efficient. The number one requirement is the...
2
by: ShieldsJared | last post by:
Hello all, So I recently found out about redirecting the Standard Output of a vbscript back to my C# app but I've found a problem. When I run a script that calls OpenTextFile, I do not receive...
1
by: itskaps | last post by:
Hi all, My following program code works fine on win 2K server but the same is not working on win2K3 server. It's showing error as page cannot be displayed. After debugging, I found that...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.