Skip to content

PowerShell logging is tightly coupled to ETW and should be refactored. #5180

@dantraMSFT

Description

@dantraMSFT

The current logging implementation in powershell is tightly coupled to ETW requiring callers to have direct and unnecessary knowledge of each ETW event, including meta data such as task, opcode, and channel,
Ideally, this interface should be generalized to a simple 'log id' and parameters as well as a general purpose log message api and completely hide the ETW details.

NOTE: For ETW, the additional meta data is already encapsulated in the EventDescriptor and requiring callers to pass it is redundant, at best, or error prone, at worse.

The refactor should move the ETW semantics down into the LogProvider implementation, refactor PSEtwLog into a logging class and support alternatives, such as syslog.

Additionally, the refactor should have a single point of entry for logging an event; whether it be ETW, Syslog or another output type. As it stands, PowerShell code contains 3 different places where events are raised and, in one case, it fabricates event descriptors on the fly. This is fragile to maintain.

Any event specific data (such as message strings, channels, etc.) can be obtained through code generators and consumed by the underlying loggers versus requiring powershell-proper to have knowledge of it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Code Cleanupthe issue is for cleaning up the code with no impact on functionalityResolution-No ActivityIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions