Best practice for threadsafe logging

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Is there any best practice guidelines or examples for threadsafe logging? I
have to write an auditlogging class for a website. The auditlog will be
stored in files on the local filesystem. A new file file is created by the
interval of 24 hours.

/m
 
martin said:
Hi,

Is there any best practice guidelines or examples for threadsafe logging?
I
have to write an auditlogging class for a website. The auditlog will be
stored in files on the local filesystem. A new file file is created by the
interval of 24 hours.

You can't use the Windows event log?

John Saunders
 
martin said:
No, I don't want to log events, I need a complete auditlog.

Ok, though I presume you're aware that it's possible to create custom event
logs, so that your audit entries would be the only thing in your custom log.

Otherwise, perhaps you should consider a database.

I don't think you're going to find a single best practice on this,
especially since you haven't been very specific about your requirements.


John Saunders
 
As I wrote in my first question the auditlog must be stored in files on the
local filesystem. I need a thread safe way to write to a file from a website.
Quite simple question I think. I can read in the SDK how to write to a file
thread safe, but I'm lokking for best practice and/or design guidelines for
the best implementation.

/m
 
martin said:
As I wrote in my first question the auditlog must be stored in files on
the
local filesystem. I need a thread safe way to write to a file from a
website.
Quite simple question I think. I can read in the SDK how to write to a
file
thread safe, but I'm lokking for best practice and/or design guidelines
for
the best implementation.

See, this is what I'm getting at. There's nothing inherently different about
writing to a file with respect to thread-safety. The same techniques you'd
use for doing anything in a thread-safe manner apply to writing to a file.

John Saunders
 
Back
Top