Skip to content

Feature: Auto debug logging when running in Debug + shared test-logging library + debug panel #143

@boexler

Description

@boexler

Summary

When developing the NLogViewer app, it would be helpful if:

  1. Auto test logging in Debug – When the application is started in Debug (e.g. F5), the same behavior as the current Sentinel.NLogViewer.App.TestApp runs automatically: generate sample log messages and send them via UDP so the viewer can display them without manually starting the separate TestApp.

  2. Shared test-logging logic – The logic currently in the TestApp (NLog target switching, timer-based log generation, random messages, exception generation) should be moved into a common/shared project so that:

    • The console TestApp becomes a thin wrapper that uses this library.
    • The main WPF app can use the same library when running in Debug.
  3. Debug panel – A debug-only panel in the main application where the user can:

    • Decide whether to create a new instance of the test log generator (with specific parameters).
    • Configure parameters (e.g. NLog target: chainsaw/log4jxml, UDP host/port, message interval, exception probability) to test logging.

Current state

  • Sentinel.NLogViewer.App.TestApp is a separate console app that:
    • Updates NLog target via NLOG_TARGET (chainsaw / log4jxml).
    • Runs a timer that generates random log messages and exceptions (20% chance) and sends them to UDP (e.g. 127.0.0.1:4000).
  • The main app Sentinel.NLogViewer.App has no built-in way to generate test logs; developers must run the TestApp separately.

Proposed approach

  • New project (e.g. Sentinel.NLogViewer.Debug or Sentinel.NLogViewer.TestLogging):
    • Contains: NLog target switching, log message generator (random levels, messages, logger names, exception injection), configurable interval and parameters.
    • Can be referenced by both the TestApp and the main App.
  • Main app (Debug only):
    • On startup in Debug: optionally auto-start the test log generator (e.g. with default parameters matching current TestApp).
    • Debug panel: UI (e.g. collapsible panel or menu item "Debug → Test logging") to start/stop a generator instance and set parameters (target, host, port, interval, exception chance).
  • TestApp: Refactor to use the shared project; keep only console entry point and "press key to stop" behavior.

Acceptance criteria

  • Test log generation logic lives in a shared project; TestApp uses it.
  • When the main app is run in Debug, test logging can run automatically (configurable).
  • Debug panel allows starting/stopping a test log generator and configuring parameters (target, UDP host/port, interval, exception probability).
  • No functional change to Release builds; debug features are conditional (e.g. #if DEBUG or runtime check).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions