Note
This procedure is for development machines. For build servers, see Troubleshooting an unattended build.
When reporting a Metalama bug, attaching Metalama log files is helpful. This article shows how to generate these logs.
You can produce log files or write the logging output to the console.
Producing log files
Step 1. Install the Metalama CLI tool
Install the metalama .NET tool as described in Installing the Metalama command line tool.
Step 2. Edit diagnostics.json
Run the following command:
metalama config edit diagnostics
This command opens a diagnostics.json file in your default editor. Make these changes:
- In the
logging/processessection, set the processes that should have logging enabled totrue:Compiler: The compile-time process.Rider: The design-time Roslyn process of the Rider IDE.DevEnv: The UI process of Visual Studio. No aspect code runs in this process.RoslynCodeAnalysisService: The design-time Roslyn process running under Visual Studio, where aspect code runs.
- In the
logging/tracesection, set the categories that should have logging enabled totrue. To enable logging for all categories, set the*category totrue.
This example shows how to enable logging for the compiler process for all categories.
{
"logging": {
"processes": {
"Other": false,
"Compiler": true,
"DevEnv": false,
"RoslynCodeAnalysisService": false,
"Rider": false,
"BackstageWorker": false,
"MetalamaConfig": false,
"TestHost": false
},
"trace": {
"*": false
},
"stopLoggingAfterHours": 5.0
}
}
To validate the correctness of the JSON file, run the following command:
metalama config validate diagnostics
Step 3. Restart processes
Diagnostic settings are cached in all processes, including background compiler processes and IDE helper processes.
To restart background compiler processes, run the following command:
metalama kill
To alter the logging configuration of the IDE processes, manually restart your IDE.
Step 4. Execute Metalama
Perform the actions you want to log.
Warning
Logging is automatically disabled after a certain number of hours following the last modification of diagnostics.json. The duration is specified in the stopLoggingAfterHours property in the logging section and defaults to 2 hours. To change this duration, edit the diagnostics.json file.
Step 5. Open the log file
Find the log in the %TEMP%\Metalama\Logs directory.