Skip to content

[BUG] LogMonitor config parser sensitive to order of waitInSeconds property in JSON #214

@mloskot

Description

@mloskot

Describe the bug

Depending on order of waitInSeconds property, configuration file is parsed as valid or invalid.

To Reproduce

Steps to reproduce the behavior:

  1. Create nonworking.json with waitInSeconds ordered this way:

    {
      "LogConfig": {
        "sources": [
          {
            "type": "File",
            "filter": "*.log",
            "directory": "C:\\data\\Logs",
            "waitInSeconds": 0,
            "includeSubdirectories": false,
            "includeFileNames": false
          }
        ]
      }
    }
  2. Run C:\LogMonitor.exe /config C:\nonworking.json an observe parsing error

    [2025-07-10T22:17:01.000Z][LOGMONITOR] ERROR: Failed to read json configuration file. JsonFileParser: Error at end of an object.
    [2025-07-10T22:17:01.000Z][LOGMONITOR] ERROR: Invalid configuration file.
  3. Create working.json with waitInSeconds moved to the end of the object:

    {
      "LogConfig": {
        "sources": [
          {
            "type": "File",
            "filter": "*.log",
            "directory": "C:\\data\\Logs",
            "includeSubdirectories": false,
            "includeFileNames": false,
            "waitInSeconds": 0
          }
        ]
      }
    }
  4. Run C:\LogMonitor.exe /config C:\working.json an observe all working

    [2025-07-10T22:15:42.000Z][LOGMONITOR] ERROR: Error in log file monitor. Failed to query file information. File: \\?\C:\data\Logs\seq-20250710.log. Error: 50
    [2025-07-10T22:15:42.000Z][LOGMONITOR] ERROR: Error in log file monitor. Failed to query file information. File: \\?\C:\data\Logs\seq-20250710.log. Error: 50

    (Those ERROR-s annoyance is benign, see Getting ERROR: Error in log file monitor. Failed to query file information [BUG] #125 (comment))

Expected behavior

The nonworking.json successfully parsed as a valid JSON.

Screenshots

n/a

Configuration
-Tool: Log Monitor
-Version: 2.1.1 (latest)

Additional context

n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions