Skip to content

Cmdline option to open file at specific line #58

Closed

Description

@hisbluness

Feature

Hey.

Long time Logexpert user (and fan!). Great that you maintain it.
I know I can start LogExpert with a filename as a CMD argument so it starts opening that file, but what I am missing is an option to also supply a specific line number so it will open up that file and go to that specific line.

Use Case:
I've written a tool that finds gaps in log files (e.g. for 24/7 running processes with rather constant log output to locate times where nothing is logged for a longer period of time). I identify these gaps automatically and want an option to open the file in LogExpert at that specific location to do further checks with proper highlighting and the comfort of LogExpert.

I know that Notepad++ can do that ("Notepad++.exe FILENAME -n LINENUMBER") and would love to have the same functionality.

Thanks!

Activity

  1. zarunbal commented on May 6, 2018

    @zarunbal
    Collaborator

    Thanks for your idea and great description! I hope that I have soon some more time to integrate the different features and fix other bugs.

  2. hisbluness commented on May 6, 2018

    @hisbluness
    Author

    No rush :-) I did look at the source, in an attempt to integrate it myself but wasn't able to yet. Adding a new cmdline argument seems fairly straight forward but I dont see a good way of calling the "GotoLine()" from there on. Anyway. I'll take a look when I have time, but I guess its a little over my head.

  3. yanivboneh commented on Sep 28, 2019

    @yanivboneh

    Hi!
    Any updates for this feature?
    Was trying to write a method that calls "GotoLine()" through the command but didnt manage to do it yet.

  4. added this to the Release 1.50.0 milestone on Jun 24, 2026
  5. Hirogen commented on Sep 7, 2026

    @Hirogen
    Member

    Implementation brief

    Category: Enhancement
    Summary: Add a command-line option to open a log file and navigate to a specified line, including when the request is forwarded to an already-running instance.

    Current behavior

    The command line accepts filenames and configuration options, but no target line. LogWindow.GotoLine(int) already provides navigation.

    Opening files is asynchronous. After loading, LogExpert restores saved session state, including selection, scroll position, and follow-tail. Simply calling GotoLine() immediately after opening the file would therefore be unreliable.

    These findings are based on source inspection; runtime verification remains part of implementation.

    Required behavior

    Support both forms:

    LogExpert.exe "C:\logs\application.log" --line 1234
    LogExpert.exe "C:\logs\application.log" -n 1234

    • Line numbers are one-based, matching the existing Go to Line dialog.
    • Accept integers from 1 through Int32.MaxValue. Reject missing, nonnumeric, zero, negative, overflowing, or repeated line arguments with a clear command-line error.
    • When a line option is supplied, require exactly one log-file argument. Reject .lxj sessions and .lxp session files for this initial implementation.
    • Select and reveal the requested line in the target Log Window.
    • Apply navigation after initial loading, session restoration, and other automatic initial positioning.
    • The explicit target overrides the restored position. Disable follow-tail for that Log Window before navigating.
    • If the target exceeds the loaded line count, select the last available line. For an empty file, leave the selection empty without throwing.
    • Preserve existing instance-routing rules: new window, locked window, or most recently active window.
    • If the selected destination already has the file open, reuse that Log Window. Navigate immediately if ready; otherwise apply the request after loading completes.
    • If multiple requests arrive for the same loading Log Window, the latest target wins.
    • Consume the request once. Reloads and rollover must not reapply it.
    • Closing the target window or failing to load the file must discard the pending request.
    • Commands without the line option retain existing behavior.

    Relevant implementation points

    Use these types and methods as entry points; locate their current definitions before editing:

    • Program.Main
      Parse and validate --line / -n; pass the target into both first-instance startup and IPC forwarding.
    • LoadPayload, SerializeCommandIntoNonFormattedJSON, SendMessageToProxy
      Carry an optional target line through IPC. Payloads without it must remain valid. Validate incoming targets as well as CLI input.
    • LogExpertProxy and ILogExpertProxy
      Preserve the target through LoadFiles, NewWindow, and NewWindowOrLockedWindow, respecting existing routing.
    • AbstractLogTabWindow.Create, LogTabWindow, ILogTabWindow
      Carry the target through window creation, startup-file loading, and requests received by an existing window.
    • FileOperationService, IFileOperationService, FileTabRequest
      Associate the target with the correct file/window, including the existing-window reuse path.
    • LogWindow.OnLogFileReaderFinishedLoading
      Coordinate one-time navigation after restoration and automatic positioning have finished.
    • LogWindow.GotoLine, FollowTailChanged
      Reuse existing navigation and tail controls. Convert the one-based CLI value to the zero-based internal index exactly once.

    Register pending navigation before asynchronous loading can complete. FileOperationService.FileOpened currently signals that opening was initiated, not that loading and restoration are complete.

    Apply UI changes on the UI thread. Do not block that thread waiting for loading, or use arbitrary delays to guess when loading has finished.

    Acceptance criteria

    • Both option names navigate to the correct line on a fresh application launch.
    • First-line, middle-line, last-line, beyond-EOF, and empty-file cases behave as specified.
    • Invalid arguments produce a clear error before opening or forwarding files.
    • Forwarding to an existing instance preserves the target for all existing routing modes.
    • An already-open file is reused and navigated correctly.
    • A request arriving while the file is loading is applied after restoration; the latest pending request wins.
    • Saved selection, saved scroll position, and follow-tail do not override the explicit target.
    • Appending lines after navigation does not pull the view to the end.
    • Reload, rollover, failed loading, and window closure do not replay a stale request.
    • Existing CLI commands and IPC payloads without a target retain their behavior.
    • Automated tests cover argument validation, actual IPC serialization/dispatch, and pending-navigation behavior.
    • Windows UI verification covers fresh startup, existing-instance forwarding, asynchronous loading, and session restoration.
    • Command-line documentation describes syntax, numbering, supported inputs, and boundary behavior.

    Scope and caveats

    This is navigation within the loaded log, not a faster partial-file loader. Large files may still require normal loading before navigation.

    For this first version, do not add per-file targets for multiple arguments, session navigation, timestamp navigation, or physical-line mapping across combined rollover files. Use the same line numbering as the existing Go to Line
    feature.

    An external tool's line number can become stale if the log rotates, is truncated, or is otherwise changed before LogExpert opens it. Preprocessing and combined-file views can also change how displayed line numbers correspond to physical file lines; this feature does not solve that mapping.

    Estimated difficulty: Moderate. The main work is carrying the target through the opening paths and applying it at the correct lifecycle point. Rough estimate: 2–4 developer days including tests and Windows UI verification.

  6. added a commit that references this issue on Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Featurewhat a great ideaenhancementthis will make things better

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions