<p>For debugging purposes in a somewhat closed system, I have to output text to a file.</p>

<p>Does anyone know of a tool that runs on windows (console based or not) that detects changes to a file and outputs them in real-time?</p>

[{'answer_id': 18635, 'author': 'Jon Galloway', 'author_id': 5, 'author_profile': 'https://Stackoverflow.com/users/5', 'pm_score': 6, 'selected': True, 'text': '<ul>\n<li><a href="http://tailforwin32.sourceforge.net/" rel="noreferrer">Tail for Win32</a></li>\n<li><a href="http://logging.apache.org/chainsaw/index.html" rel="noreferrer">Apache Chainsaw</a> - used this with <a href="http://logging.apache.org/log4net/release/howto/chainsaw.html" rel="noreferrer">log4net logs</a>, may require file to be in a certain format</li>\n</ul>\n'}, {'answer_id': 18637, 'author': 'Rob Cooper', 'author_id': 832, 'author_profile': 'https://Stackoverflow.com/users/832', 'pm_score': 2, 'selected': False, 'text': '<p>I have used <a href="http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx" rel="nofollow noreferrer">FileSystemWatcher</a> for monitoring of text files for a component I recently built. There may be better options (I never found anything in my <em>limited</em> research) but that seemed to do the trick nicely :)</p>\n\n<p>Crap, my bad, you\'re actually after a tool to do it all for you..</p>\n\n<p>Well if you get unlucky and want to roll your own ;)</p>\n'}, {'answer_id': 18638, 'author': 'CHitchcock', 'author_id': 2179, 'author_profile': 'https://Stackoverflow.com/users/2179', 'pm_score': 4, 'selected': False, 'text': '<p>I use "tail -f" under cygwin.</p>\n'}, {'answer_id': 18640, 'author': 'ZombieSheep', 'author_id': 377, 'author_profile': 'https://Stackoverflow.com/users/377', 'pm_score': 3, 'selected': False, 'text': '<p>FileSystemWatcher works a treat, although you do have to be a little careful about duplicate events firing - <a href="http://blogs.msdn.com/ahamza/archive/2006/02/04/FileSystemWatcher-Duplicate-Events.aspx" rel="nofollow noreferrer">1st link from Google</a> - but bearing that in mind can produce great results.</p>\n'}, {'answer_id': 18648, 'author': 'Nelson Miranda', 'author_id': 1130097, 'author_profile': 'https://Stackoverflow.com/users/1130097', 'pm_score': 1, 'selected': False, 'text': '<p>Yor can use the FileSystemWatcher in System.Diagnostics.</p>\n\n<p>From MSDN:</p>\n\n<p>public class Watcher\n{</p>\n\n<pre><code>public static void Main()\n{\nRun();\n\n}\n\n[PermissionSet(SecurityAction.Demand, Name="FullTrust")]\npublic static void Run()\n{\n    string[] args = System.Environment.GetCommandLineArgs();\n\n    // If a directory is not specified, exit program.\n    if(args.Length != 2)\n    {\n        // Display the proper way to call the program.\n        Console.WriteLine("Usage: Watcher.exe (directory)");\n        return;\n    }\n\n    // Create a new FileSystemWatcher and set its properties.\n    FileSystemWatcher watcher = new FileSystemWatcher();\n    watcher.Path = args[1];\n    /* Watch for changes in LastAccess and LastWrite times, and \n       the renaming of files or directories. */\n    watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite \n       | NotifyFilters.FileName | NotifyFilters.DirectoryName;\n    // Only watch text files.\n    watcher.Filter = "*.txt";\n\n    // Add event handlers.\n    watcher.Changed += new FileSystemEventHandler(OnChanged);\n    watcher.Created += new FileSystemEventHandler(OnChanged);\n    watcher.Deleted += new FileSystemEventHandler(OnChanged);\n    watcher.Renamed += new RenamedEventHandler(OnRenamed);\n\n    // Begin watching.\n    watcher.EnableRaisingEvents = true;\n\n    // Wait for the user to quit the program.\n    Console.WriteLine("Press \\\'q\\\' to quit the sample.");\n    while(Console.Read()!=\'q\');\n}\n\n// Define the event handlers.\nprivate static void OnChanged(object source, FileSystemEventArgs e)\n{\n    // Specify what is done when a file is changed, created, or deleted.\n   Console.WriteLine("File: " +  e.FullPath + " " + e.ChangeType);\n}\n\nprivate static void OnRenamed(object source, RenamedEventArgs e)\n{\n    // Specify what is done when a file is renamed.\n    Console.WriteLine("File: {0} renamed to {1}", e.OldFullPath, e.FullPath);\n}\n</code></pre>\n\n<p>}</p>\n\n<p>You can also follow this link <a href="http://www.codeproject.com/KB/dotnet/folderwatcher.aspx" rel="nofollow noreferrer">Watching Folder Activity in VB.NET</a></p>\n'}, {'answer_id': 18664, 'author': 'Lars Truijens', 'author_id': 1242, 'author_profile': 'https://Stackoverflow.com/users/1242', 'pm_score': 0, 'selected': False, 'text': '<p><a href="http://technet.microsoft.com/en-us/sysinternals/bb896642.aspx" rel="nofollow noreferrer">FileMon</a> is a free stand alone tool that can detect all kinds of file access. You can filter out any unwanted. It does not show you the data that has actually changed though.</p>\n'}, {'answer_id': 18667, 'author': 'Owen', 'author_id': 2109, 'author_profile': 'https://Stackoverflow.com/users/2109', 'pm_score': 0, 'selected': False, 'text': '<p>I second "tail -f"  in cygwin.  I assume that Tail for Win32 will accomplish the same thing.</p>\n'}, {'answer_id': 18670, 'author': 'Lars Truijens', 'author_id': 1242, 'author_profile': 'https://Stackoverflow.com/users/1242', 'pm_score': 4, 'selected': False, 'text': '<p>When using <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" rel="noreferrer">Windows PowerShell</a> you can do the following: </p>\n\n<pre><code>Get-Content someFile.txt -wait\n</code></pre>\n'}, {'answer_id': 18672, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 3, 'selected': False, 'text': '<p>Tail is the best answer so far.</p>\n\n<p>If you don\'t use Windows, you probably already have tail.</p>\n\n<p>If you do use Windows, you can get a whole slew of Unix command line tools from <a href="http://unxutils.sourceforge.net/" rel="nofollow noreferrer">here</a>. Unzip them and put them somewhere in your PATH.</p>\n\n<p>Then just do this at the command prompt from the same folder your log file is in:</p>\n\n<pre><code>tail -n 50 -f whatever.log\n</code></pre>\n\n<p>This will show you the last 50 lines of the file and will update as the file updates.</p>\n\n<p>You can combine grep with tail with great results - something like this:</p>\n\n<pre><code>tail -n 50 -f whatever.log | grep Error\n</code></pre>\n\n<p>gives you just lines with "Error" in it.</p>\n\n<p>Good luck!</p>\n'}, {'answer_id': 18690, 'author': 'John Topley', 'author_id': 1450, 'author_profile': 'https://Stackoverflow.com/users/1450', 'pm_score': 4, 'selected': False, 'text': '<p>I use <a href="http://www.baremetalsoft.com/baretail/" rel="noreferrer">BareTail</a> for doing this on Windows. It\'s free and has some nice features, such as tabs for tailing multiple files and configurable highlighting.</p>\n'}, {'answer_id': 18726, 'author': 'Dillie-O', 'author_id': 71, 'author_profile': 'https://Stackoverflow.com/users/71', 'pm_score': 1, 'selected': False, 'text': '<p>Just a shameless plug to tail onto the answer, but I have a free web based app called <a href="http://www.codeplex.com/hacksaw" rel="nofollow noreferrer">Hacksaw</a> used for viewing log4net files. I\'ve put in an auto refresh options so you can give yourself near real time updates without having to refresh the browser all the time.</p>\n'}, {'answer_id': 25247, 'author': 'ryan', 'author_id': 2454, 'author_profile': 'https://Stackoverflow.com/users/2454', 'pm_score': 1, 'selected': False, 'text': "<p>Yeah I've used both Tail for Win32 and tail on Cygwin. I've found both to be excellent, although I prefer Cygwin slightly as I'm able to tail files over the internet efficiently without crashes (Tail for Win32 has crashed on me in some instances).</p>\n\n<p>So basically, I would use tail on Cygwin and redirect the output to a file on my local machine. I would then have this file open in Vim and reload (:e) it when required. </p>\n"}, {'answer_id': 25278, 'author': 'Rob Thomas', 'author_id': 803, 'author_profile': 'https://Stackoverflow.com/users/803', 'pm_score': 1, 'selected': False, 'text': '<p>+1 for BareTail.  I actually use <a href="http://www.baremetalsoft.com/baretailpro/index.php" rel="nofollow noreferrer">BareTailPro</a>, which provides real-time filtering on the tail with basic search strings or search strings using regex.</p>\n'}, {'answer_id': 39616, 'author': 'Mike Schall', 'author_id': 4231, 'author_profile': 'https://Stackoverflow.com/users/4231', 'pm_score': 6, 'selected': False, 'text': '<p>I like tools that will perform more than one task, Notepad++ is a great notepad replacement and has a Document Monitor plugin (installs with standard msi) that works great. It also is portable so you can have it on a thumb drive for use anywhere.</p>\n\n<p>For a command line option, PowerShell (which is really a new command line) has a great feature already mentioned.</p>\n\n<pre><code>Get-Content someFile.txt -wait\n</code></pre>\n\n<p>But you can also filter at the command line using a regular expression</p>\n\n<pre><code>Get-Content web.log -wait | where { $_ -match "ERROR" }\n</code></pre>\n'}, {'answer_id': 128126, 'author': 'Charley Rathkopf', 'author_id': 10119, 'author_profile': 'https://Stackoverflow.com/users/10119', 'pm_score': 0, 'selected': False, 'text': '<p><a href="http://tailforwin32.sourceforge.net/" rel="nofollow noreferrer">Tail for Win32</a></p>\n'}, {'answer_id': 1092341, 'author': 'mandrake', 'author_id': 128643, 'author_profile': 'https://Stackoverflow.com/users/128643', 'pm_score': 1, 'selected': False, 'text': '<p>To make the list complete here\'s a link to the GNU WIN32 ports of many useful tools (amongst them is tail).\n<a href="http://gnuwin32.sourceforge.net/packages/coreutils.htm" rel="nofollow noreferrer">GNUWin32 CoreUtils</a></p>\n'}, {'answer_id': 10699057, 'author': 'Simon', 'author_id': 1409799, 'author_profile': 'https://Stackoverflow.com/users/1409799', 'pm_score': 1, 'selected': False, 'text': '<p>Surprised no one has mentioned Trace32 (or Trace64). These are great (free) Microsoft utilities that give a nice GUI and highlight any errors, etc. It also has filtering and sounds like exactly what you need. </p>\n'}, {'answer_id': 18888584, 'author': 'Contango', 'author_id': 107409, 'author_profile': 'https://Stackoverflow.com/users/107409', 'pm_score': 2, 'selected': False, 'text': '<p>Try SMSTrace from Microsoft (now called CMTrace, and directly available in the Start Menu on some versions of Windows)</p>\n\n<p>Its a brilliant GUI tool that monitors updates to any text file in real time, even if its locked for writing by another file.</p>\n\n<p>Don\'t be fooled by the description, its capable of monitoring any file, including .txt, .log or .csv.</p>\n\n<p><strong>Its ability to monitor locked files is extremely useful</strong>, and is one of the reasons why this utility shines.</p>\n\n<p>One of the nicest features is line coloring. If it sees the word "ERROR", the line becomes red. If it sees the word "WARN", the line becomes yellow. This makes the logs a lot easier to follow.</p>\n'}, {'answer_id': 23080368, 'author': 'managedheap84', 'author_id': 627304, 'author_profile': 'https://Stackoverflow.com/users/627304', 'pm_score': 1, 'selected': False, 'text': '<p>Here\'s a utility I wrote to do just that:</p>\n\n<p>It uses a FileSystemWatcher to look for changes in log files within local folders or network shares (don\'t have to be mounted, just provide the UNC path) and appends the new content to the console.</p>\n\n<p>on github: <a href="https://github.com/danbyrne84/multitail" rel="nofollow">https://github.com/danbyrne84/multitail</a></p>\n\n<p><a href="http://www.danielbyrne.net/projects/multitail" rel="nofollow">http://www.danielbyrne.net/projects/multitail</a></p>\n\n<p>Hope this helps</p>\n'}, {'answer_id': 25441030, 'author': 'Grim', 'author_id': 843943, 'author_profile': 'https://Stackoverflow.com/users/843943', 'pm_score': 0, 'selected': False, 'text': '<p>I did a tiny viewer by my own:</p>\n\n<p><a href="https://github.com/enexusde/Delphi/wiki/TinyLog" rel="nofollow">https://github.com/enexusde/Delphi/wiki/TinyLog</a></p>\n'}, {'answer_id': 30055017, 'author': 'Erick Alves', 'author_id': 1286563, 'author_profile': 'https://Stackoverflow.com/users/1286563', 'pm_score': 2, 'selected': False, 'text': '<p>Snake Tail. It is a good option.\n<a href="http://snakenest.com/snaketail/" rel="nofollow">http://snakenest.com/snaketail/</a></p>\n'}, {'answer_id': 31784380, 'author': 'Ragav', 'author_id': 1153349, 'author_profile': 'https://Stackoverflow.com/users/1153349', 'pm_score': 3, 'selected': False, 'text': '<p>Late answer, though might be helpful for someone -- <a href="http://www.log-expert.de/" rel="noreferrer">LOGEXPERT</a> seems to be interesting tail utility for windows.</p>\n'}, {'answer_id': 34039182, 'author': 'Chaitanya', 'author_id': 2031870, 'author_profile': 'https://Stackoverflow.com/users/2031870', 'pm_score': 1, 'selected': False, 'text': '<pre><code>@echo off\n\nset LoggingFile=C:\\foo.txt\nset lineNr=0\n\n:while1\nfor /f "usebackq delims=" %%i in (`more +%lineNr% %LoggingFile%`) DO (\n    echo %%i\n    set /a lineNr+=1\n    REM Have an appropriate stop condition here by checking i\n)\ngoto :while1\n</code></pre>\n\n<p>A command prompt way of doing it. </p>\n'}]
['https://Stackoverflow.com/questions/18632', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2011/']