AddJunctionLogger
Package Trax.Effect.JunctionProvider.LoggingNamespace Trax.Effect.JunctionProvider.Logging.ExtensionsSource ServiceExtensions.cs
Adds the junction logger, a junction effect that writes each junction's metadata (name, start and end times,
duration, input and output types, railway state) to ILogger before and after the junction runs. Nothing is written
to the database.
Signature
public static TBuilder AddJunctionLogger<TBuilder>(
this TBuilder configurationBuilder,
bool serializeJunctionData = false
)
where TBuilder : TraxEffectBuilderParameters
| Parameter | Type | Default | Description |
|---|---|---|---|
serializeJunctionData | bool | false | Serialize each successful junction's output into its metadata's OutputJson, so the after-junction entry carries it. Junction input is never serialized. |
Returns
TBuilder, the builder type it was called on.
Behavior
Registers the logger's factory with AddJunctionEffect, as a toggleable junction effect, and sets the builder's
SerializeJunctionData. Entries are written at the effect log level
under the category Trax.Effect.JunctionProvider.Logging.Services.JunctionLoggerProvider.JunctionLoggerProvider.
Only EffectJunctions are logged. Each entry carries the junction's metadata as a masked JSON string (the
argument {JunctionMetadata} before the junction runs, {Metadata} after), never the record itself.
With serializeJunctionData: true, the output copy follows the train's lifecycle hook output policy:
- none for a train whose output SaveTrainParameters excludes;
- at most
MaxParameterBytes(1 MiB by default), past which it is{"_truncated": true, "_maxBytes": N}; {"_unserializable": true, "_error": "<exception type>"}when it cannot be serialized. Serializing never fails the train.
Members marked [TraxSensitive] are written as {"_redacted": true}, and the copies a train is run from (a
manifest's Properties, a queued entry's Input, a background job's Input) as {"_omitted": true}.
Example
services.AddTrax(trax => trax
.AddEffects(effects => effects
.UsePostgres(connectionString)
.AddJunctionLogger(serializeJunctionData: true)
)
.AddMediator(typeof(IShipOrderTrain).Assembly)
);