OpenTextFile and logging

J

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
 
R

Ray at

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
 
F

Foo Man Chew

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).
 
F

Foo Man Chew

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.
 
J

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top