The first lines from a file monitored by the File source are lost, when the file and directory monitored by LogMonitor are created after LogMonitor was started.
To Reproduce
Steps to reproduce the behavior:
Monitored directory must not exist (e.g. C:\Logfiles)
Start LogMonitor
Observe the following expected log output from LogMonitor:
INFO: Log directory \\?\c:\Logfiles does not exist. LogMonitor will wait for 300 seconds for the directory to be created.
Write to the log file (e.g. C:\Logfiles\test\app.log), which includes creating it as well as parent directories
Observe the following expected log output from LogMonitor:
INFO: Log directory \\?\c:\Logfiles found after 15 seconds.
UNEXPECTED: First lines from the log file are missing (more specifically everything written after 4. but before 5. is lost)
Reproduction hints:
I could not reproduce this behavior, when pre-creating the directory C:\Logfiles. It was not even necessary to create the sub-directory test or the file, before I started LogMonitor.
I could reproduce this behavior regardless of the flag includeSubdirectories, i.e. with it set to true and false.
Expected behavior
LogMonitor picks up all lines from a file, even when the directory to monitor is created after startup.
Describe the bug
The first lines from a file monitored by the File source are lost, when the file and directory monitored by LogMonitor are created after LogMonitor was started.
To Reproduce Steps to reproduce the behavior:
C:\Logfiles
)INFO: Log directory \\?\c:\Logfiles does not exist. LogMonitor will wait for 300 seconds for the directory to be created.
C:\Logfiles\test\app.log
), which includes creating it as well as parent directoriesINFO: Log directory \\?\c:\Logfiles found after 15 seconds.
Reproduction hints:
C:\Logfiles
. It was not even necessary to create the sub-directorytest
or the file, before I started LogMonitor.includeSubdirectories
, i.e. with it set totrue
andfalse
.Expected behavior
LogMonitor picks up all lines from a file, even when the directory to monitor is created after startup.
The source code even suggests it should: https://github.com/microsoft/windows-container-tools/blob/aa6ea069f327ca1c63dfc0a672ca4e9ab41c989f/LogMonitor/src/LogMonitor/FileMonitor/FileMonitorUtilities.cpp#L66
Configuration -Tool: LogMonitor -Version: 2.0.2 (and 2.0.0)
Additional context
To reproduce the issue, you may use the following files. Put them in the following directory hierarchy:
Then build & run the container image.
Dockerfile
entrypoint.ps1
LogMonitorConfig.json
Example output