Skip to content

[FeatureRequest] Alternative Logging Implementation #415

Description

The current logging hierarchy puts Verbose "below" debug in the log level, which is counter to common Powershell convention:

  • Verbose is for higher, user-level detail as to what a command is doing
  • Debug is for lower level Developer output such as current variable states and method call tracing

As such, if you enable LogLevel for "Debug", you will get debug messages before you get verbose message, and if you set "Trace" you then get the "higher-level" messages, but there is no effective way through to get only Verbose messages but not debug messages without first setting to trace and then manipulating verbosepreference.

Further, since $DebugPreference and $VerbosePreference are off by default in an Azure Function, this confuses users who try Write-Debug and Write-Verbose and dont' realize they need the -verbose and -debug additions

There should be an extension setting (to allow for backward compatibility) for an alternative logging implementation that does the following:

  • Verbose and Information are set to the Information stream
  • Debug is sent to Debug stream
  • If loglevel is set to Debug, $DebugPreference = 'continue' should be set by default. The user can always override it with $DebugPreference = 'SilentlyContinue' in the script
  • Output is sent to the trace stream (since output in Azure Functions is purely for logging, this can now be thought of as used for Trace Activites)

Since verbosepreference is off by default, this would allow the following workflow:

  • I just want information output on the function: Loglevel Information. Use Write-Host or Write-Information for the equivalent of console output.
  • I want verbose info: LogLevel information and set VerbosePreference='continue' in my script
  • I want debug info: LogLevel Debug
  • I want trace info: I write my trace info to Output and set loglevel to Trace

This would also carry through to Application Insights appropriately, and make it much easier to dive into a function issue just by manipulating the host.json loglevel.

Future major version may want to consider this the default method to be more intuitive to functions users.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions