Visual C++ .NET 2009 'Stealing' file handles

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fazzone
    New Member
    • Oct 2008
    • 2

    Visual C++ .NET 2009 'Stealing' file handles

    For a project I am working on, I have to check a game's log file for certain events. Currently, i am using a FileSystemWatch er class to watch for log changes, and then copy the log and read from where I left off to check for more events. However, the log only flushes to disk when it gets enough messages, and it would be best to be able to read it in real-time. Is there a way to 'steal/hijack' the log file handle and either read the file buffer in real-time or force it to flush in .NET?
  • pootle
    New Member
    • Apr 2008
    • 68

    #2
    Why are you re-inventing the wheel?

    This type of logging system is available in several flavours as .NET libraries. You could use NLog or log4net.

    These all provide the ability to send log files over the network, to send to a syslog collector, to store in files - almost anything you can image and are highly extensible if the exact behaviour you want is not available. You will save yourself a lot of time and heartache if you use a good logging library...

    NLog
    http://www.nlog-project.org/

    log4Net
    http://logging.apache. org/log4net/index.html

    HTH

    Comment

    • fazzone
      New Member
      • Oct 2008
      • 2

      #3
      I'm not writing a logging system itself, i need to read in real-time a log file that flushes intermittently. With the FileSystemWatch er, i can only react to changes when the log is flushed, not in real-time. Is there a way to find the file handle used for this file, and react to changes in real-time as they are sent to the IO buffer?

      Comment

      Working...