<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: On windows, I sometimes get an error during log rotation if splunk is monitoring that file; what's that about? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/On-windows-I-sometimes-get-an-error-during-log-rotation-if/m-p/30207#M5248</link>
    <description>&lt;P&gt;It's hard to be certain based on the description provided, but this is PROBABLY a problem with creating a new logfile.&lt;/P&gt;

&lt;P&gt;In Windows, if your program is writing out, say sql_logfile.log, and splunk is reading sql_logfile.log, a problem can arise during rotation, that goes like this:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;Usually the writing app is told to close the logfile first, and does.&lt;/LI&gt;
&lt;LI&gt;Some program, often the writing app, sometimes a log rotator renames the file to sql_logfile.log.1&lt;/LI&gt;
&lt;LI&gt;* This works, despite the fact that Splunk has the file open, because we open the file SHARE_DELETE, permitting the file to be "deleted" out from under us.  Windows considers this type of rename scenario to be a delete for file open purposes.&lt;/LI&gt;
&lt;LI&gt;Splunk has not yet tried to read from this file again.  If it did, it would close the file.  That will happen soon.&lt;/LI&gt;
&lt;LI&gt;The writing program tries to create a &lt;EM&gt;new&lt;/EM&gt; sql_logfile.log&lt;/LI&gt;
&lt;LI&gt;* This fails, because windows does not permit a new logfile to be created with the same name as the deleted logfile until all programs have closed the deleted file.&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;There is no solution to this, short of rewriting Splunk data collection as a system call hook oriented tool, or a kernel driver.  Both of which would greatly increase the risk of causing harm to the system while collecting information.&lt;/P&gt;

&lt;P&gt;Generally speaking, the file semantics on Windows do not support rotating logs in this fashion.  Renaming live files is problematic in a number of different ways.  Thus most Windows-native apps will follow a strategy of creating files named for the time or date, and not renaming them.  If that's an option for you I recommend it.&lt;/P&gt;

&lt;P&gt;If it's not an option, you could try using the setting time_before_close = 0 on an input pointing at these files.  That does not eliminate this problem, but should drastically shrink the time window during which splunk has the files open, making it occur less frequently.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 14:32:42 GMT</pubDate>
    <dc:creator>jrodman</dc:creator>
    <dc:date>2020-09-28T14:32:42Z</dc:date>
    <item>
      <title>On windows, I sometimes get an error during log rotation if splunk is monitoring that file; what's that about?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/On-windows-I-sometimes-get-an-error-during-log-rotation-if/m-p/30206#M5247</link>
      <description>&lt;P&gt;I do a rotate sql log frequently. Splunk is monitoring my log files&lt;BR /&gt;
There are sometime error on the SQL log file rotation process&lt;/P&gt;

&lt;P&gt;Is it really the Splunk process that cause the issue?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2013 08:42:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/On-windows-I-sometimes-get-an-error-during-log-rotation-if/m-p/30206#M5247</guid>
      <dc:creator>edelawoevre</dc:creator>
      <dc:date>2013-08-09T08:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: On windows, I sometimes get an error during log rotation if splunk is monitoring that file; what's that about?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/On-windows-I-sometimes-get-an-error-during-log-rotation-if/m-p/30207#M5248</link>
      <description>&lt;P&gt;It's hard to be certain based on the description provided, but this is PROBABLY a problem with creating a new logfile.&lt;/P&gt;

&lt;P&gt;In Windows, if your program is writing out, say sql_logfile.log, and splunk is reading sql_logfile.log, a problem can arise during rotation, that goes like this:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;Usually the writing app is told to close the logfile first, and does.&lt;/LI&gt;
&lt;LI&gt;Some program, often the writing app, sometimes a log rotator renames the file to sql_logfile.log.1&lt;/LI&gt;
&lt;LI&gt;* This works, despite the fact that Splunk has the file open, because we open the file SHARE_DELETE, permitting the file to be "deleted" out from under us.  Windows considers this type of rename scenario to be a delete for file open purposes.&lt;/LI&gt;
&lt;LI&gt;Splunk has not yet tried to read from this file again.  If it did, it would close the file.  That will happen soon.&lt;/LI&gt;
&lt;LI&gt;The writing program tries to create a &lt;EM&gt;new&lt;/EM&gt; sql_logfile.log&lt;/LI&gt;
&lt;LI&gt;* This fails, because windows does not permit a new logfile to be created with the same name as the deleted logfile until all programs have closed the deleted file.&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;There is no solution to this, short of rewriting Splunk data collection as a system call hook oriented tool, or a kernel driver.  Both of which would greatly increase the risk of causing harm to the system while collecting information.&lt;/P&gt;

&lt;P&gt;Generally speaking, the file semantics on Windows do not support rotating logs in this fashion.  Renaming live files is problematic in a number of different ways.  Thus most Windows-native apps will follow a strategy of creating files named for the time or date, and not renaming them.  If that's an option for you I recommend it.&lt;/P&gt;

&lt;P&gt;If it's not an option, you could try using the setting time_before_close = 0 on an input pointing at these files.  That does not eliminate this problem, but should drastically shrink the time window during which splunk has the files open, making it occur less frequently.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:32:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/On-windows-I-sometimes-get-an-error-during-log-rotation-if/m-p/30207#M5248</guid>
      <dc:creator>jrodman</dc:creator>
      <dc:date>2020-09-28T14:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: On windows, I sometimes get an error during log rotation if splunk is monitoring that file; what's that about?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/On-windows-I-sometimes-get-an-error-during-log-rotation-if/m-p/30208#M5249</link>
      <description>&lt;P&gt;@jrodman - Do you know if this is still relevant ~7 years later? We're currently trying to monitor a third-party system that rolls logs like this, and we seem to be running into the same issue. Is the workaround still the same?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 19:38:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/On-windows-I-sometimes-get-an-error-during-log-rotation-if/m-p/30208#M5249</guid>
      <dc:creator>bruceclarke</dc:creator>
      <dc:date>2020-01-28T19:38:20Z</dc:date>
    </item>
  </channel>
</rss>

