Thread: reading log files as they're being appended

  1. #1
    Registered User guesst's Avatar
    Join Date
    Feb 2008
    Location
    Lehi, UT
    Posts
    179

    reading log files as they're being appended

    I have a program that is constantly writing to a log file. At the moment I check on it by opening the log file in notepad, closing it and reopening it. Then I see that OSX has a really groovy console utility for viewing logs as they're being written and I though there has got to be something like that for windows. Any suggestions?
    Type-ins are back! Visit Cymon's Games at http://www.cymonsgames.com for a new game every week!

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    At first open, read the file (perhaps start from the back and read only X lines from the back)
    Then, when you have found the last line, you try to read some from the file. If you get EOF immediately, sleep for x ms, then try again.

    You could possibly use the Windows API that signals changes to files, but I doubt it's really necessary. See this, if you are interested: http://msdn.microsoft.com/en-us/libr...17(VS.85).aspx

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    BareTail is what I use.

  4. #4
    Registered User guesst's Avatar
    Join Date
    Feb 2008
    Location
    Lehi, UT
    Posts
    179
    baretail looks good. It'd be nice if it were free, but oh well.
    Type-ins are back! Visit Cymon's Games at http://www.cymonsgames.com for a new game every week!

  5. #5
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    There is a free, and a registered version.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. reading files
    By hiya in forum C++ Programming
    Replies: 7
    Last Post: 05-21-2005, 11:40 AM
  2. Reading data from consecutively named files
    By a1pro in forum C Programming
    Replies: 10
    Last Post: 04-15-2005, 01:48 AM
  3. reading from files
    By recluse in forum C Programming
    Replies: 25
    Last Post: 12-26-2004, 10:33 AM
  4. Reading files in a directory
    By roktsyntst in forum Windows Programming
    Replies: 5
    Last Post: 02-07-2003, 10:04 AM
  5. reading input files with different types of data
    By sanu in forum C++ Programming
    Replies: 4
    Last Post: 06-27-2002, 08:15 AM