Logger

LoadStrike writes runtime logs for you by default. Use this page when you want to understand that default behavior or replace it with your own logger setup.

What this page helps you do

What this page helps you do

LoadStrike writes runtime logs for you by default. Use this page when you want to understand that default behavior or replace it with your own logger setup.

Who this is for

Engineers writing or reviewing scenario code in one of the supported SDKs.

Prerequisites

  • A scenario or runtime surface you want to wire correctly in code

By the end

The exact SDK surface you need for this part of the runtime.

Use this page when

Use this reference when you already know the workflow and need the exact Logger API surface in code.

Visual guide

Sequence diagram showing how a LoadStrike workflow moves from setup to report output.
This page fits into the same setup, run, correlate, and report flow as the rest of the public LoadStrike runtime.

Guide

Default Behavior

With no extra setup, LoadStrike writes normal runtime logs to the console and to one text file in the configured report folder. The default file name follows loadstrike-log-<yyyyMMdd_HHmmss>[-coordinator|-agent][-machine].txt, and clustered runs only add node role or machine suffixes when needed to keep files distinct.

Minimum Level

Use WithMinimumLogLevel, withMinimumLogLevel, or with_minimum_log_level when the run should filter out lower-level events. Supported public levels are Verbose, Debug, Information, Warning, Error, and Fatal, and JSON or CLI configuration can use the same names or numeric 0 through 5 tokens.

Custom Logger Configuration

Use WithLoggerConfig, withLoggerConfig, or with_logger_config when logs need to go somewhere else. In .NET the callback returns a Serilog LoggerConfiguration, while Java, Python, TypeScript, and JavaScript expose the same idea through their native logger callback shapes.

Replacement Rule

A custom logger configuration replaces the default public logger pipeline. If you still want a text log file after overriding the logger, add file output inside your custom logger configuration.

Console Metrics Snapshots

DisplayConsoleMetrics shows live request, ok, and fail counters separately from the logger when realtime metrics are enabled. Those snapshot lines stay independent from the normal logger pipeline, so they can still appear even after the logger configuration is replaced.

Cluster Behavior

Each node writes its own log file. Local dev clusters place child node logs under node-specific report folders, and the final LoadStrikeRunResult includes the collected log file paths in LogFiles or logFiles when the coordinator can observe them.

Language Differences

The core model stays the same across SDKs, but a few helpers and result shapes use language-specific names. Check these notes when you switch languages or compare samples.

.NET

Use WithLoggerConfig(() => new LoggerConfiguration(...)) when you want Serilog sinks, enrichers, or custom formatting.

Java, Python, TypeScript, JavaScript

Use the native logger callback surface for that SDK. The behavior is the same, but the callback returns a language-native logger object instead of a Serilog configuration.

SDK reference samples

Use these SDK samples to compare how Logger is exposed across the supported languages before you wire it into a full scenario.

If you run these examples locally, add a valid runner key before execution starts. Set it with WithRunnerKey("...") or the config key LoadStrike:RunnerKey.

Logger

using LoadStrike;
using System;
using Serilog;
using Serilog.Events;

var scenario = LoadStrikeScenario
    .Create("submit-orders", _ => Task.FromResult(LoadStrikeResponse.Ok(statusCode: "200")))
    .WithLoadSimulations(LoadStrikeSimulation.Inject(rate: 10, interval: TimeSpan.FromSeconds(1), during: TimeSpan.FromSeconds(20)));

LoadStrikeRunner.RegisterScenarios(scenario)
    .WithReportFolder("./reports")
    .WithMinimumLogLevel(LogEventLevel.Information)
    .DisplayConsoleMetrics(true)
    .WithLoggerConfig(() => new LoggerConfiguration()
        .WriteTo.Console()
        .WriteTo.File("./custom-logs/orders.log"))
    .WithRunnerKey("rkl_your_local_runner_key")
    .Run();

Logger APIs

Most teams can start with the default logger. LoadStrike writes to the console and to one loadstrike-log-<yyyyMMdd_HHmmss>[-coordinator|-agent][-machine].txt file in the report folder, so custom logger setup is only needed when logs must go somewhere else.

Default logger pipeline

By default the SDK writes runtime logs to console and to one text file inside the report folder. The final LoadStrikeRunResult also exposes those paths through LogFiles / logFiles.

Default log file name

Single-node runs use loadstrike-log-<yyyyMMdd_HHmmss>.txt in the report folder. Clustered runs can append coordinator, agent, and machine suffixes when that is needed to keep node files distinct.

WithMinimumLogLevel / withMinimumLogLevel / with_minimum_log_level

Sets the minimum runtime log level so lower-priority events are filtered before the logger writes them. Verbose, Debug, Information, Warning, Error, and Fatal are supported.

WithLoggerConfig / withLoggerConfig / with_logger_config

Replaces the default public logger pipeline with your project-specific logger. .NET expects a Serilog LoggerConfiguration callback; Java, Python, TypeScript, and JavaScript expect native logger factories or callback objects.

Replacement behavior

Custom logger configuration does not layer on top of the default file logger. If you still need a log file after overriding the logger, add file output inside your custom logger configuration.

DisplayConsoleMetrics / displayConsoleMetrics / display_console_metrics

Prints live [HH:mm:ss] requests/ok/fail snapshots separately from the logger when realtime metrics are enabled. Those snapshot lines still appear even when the normal logger pipeline is customized.

Named and numeric levels

JSON and CLI configuration accept the same public level names plus numeric 0 through 5 tokens. Invalid values are ignored so the current/default level stays active.

.NET Serilog sinks

Because .NET uses Serilog LoggerConfiguration, the same callback can attach any Serilog sink package already referenced by the application, such as file, Seq, Elasticsearch, or database sinks.