chocolatey / chocolatey/choco

Trace logging unable to be set on Mono

Open
#2,423 1 comment 0 reactions 0 assignees View on GitHub
0 - Triaging Blocked - External Enhancement Priority - Low
Dominant language
C#
Stars
11.5k
Forks
960
PR merge metrics
No merged PRs in 30d

Description

### What You Are Seeing?

When running choco with `--trace` on mono, it fails to set trace logging.

### What is Expected?

Trace logging works on mono.

### How Did You Get This To Happen? (Steps to Reproduce)

Run choco with `--trace`

### Why this is probably happening.

In mono, the members that are used trace logging exist, but are just stubbed out as far as I can tell, so `GetValue` fails on them.
https://github.com/chocolatey/choco/blob/e6492435497281074a2b5a35e2ff81fa8394881d/src/chocolatey/infrastructure/logging/TraceLog.cs#L91
https://github.com/chocolatey/choco/blob/e6492435497281074a2b5a35e2ff81fa8394881d/src/chocolatey/infrastructure/logging/TraceLog.cs#L80-L83
https://github.com/mono/mono/blob/08361379e601b2e7231c2d0e973241d6e7d14bff/mcs/class/referencesource/System/net/System/Net/Logging.cs#L50-L55

So, I'm not sure that this fixable, at least not without major mono patches.

### Output Log

choco --verbose --debug --trace

~~~sh
Chocolatey v0.11.2-51-g43132590 (DEBUG BUILD)
Unable to set trace logging:
Object reference not set to an instance of an object
Chocolatey is running on Linux v 5.10.0.0
Attempting to delete file "/path/choco/code_drop/chocolatey/console/chocolatey.dll.old".
Attempting to delete file "/path/choco/code_drop/chocolatey/console/choco.exe.old".
Attempting to create directory "/path/choco/code_drop/chocolatey/console/helpers".
Attempting to create directory "/path/choco/code_drop/chocolatey/console/helpers/functions".
Attempting to create directory "/path/choco/code_drop/chocolatey/console/redirects".
Attempting to create directory "/path/choco/code_drop/chocolatey/console/tools".
Command line: /path/choco/code_drop/chocolatey/console/choco.exe --trace --verbose --debug
Received arguments: --trace --verbose --debug
RemovePendingPackagesTask is now ready and waiting for PreRunMessage.
Sending message 'PreRunMessage' out if there are subscribers...
[Pending] Removing all pending packages that should not be considered installed...
Directory '/path/choco/code_drop/chocolatey/console/lib' does not exist.
Sending message 'PostRunMessage' out if there are subscribers...
Exiting with 1
Exiting with 1
Press enter to continue...

~~~

Contributor guide

Open the contributing guide

Research direction

Start in src/chocolatey/infrastructure/logging/TraceLog.cs at the referenced lines, then reproduce choco --trace under Mono and inspect the referenced Mono logging implementation. Determine whether a supported fallback exists for the stubbed members and verify that trace logging no longer reports the null-reference failure on Mono.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
cli, observability
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.