Skip to content

Commit af1d52a

Browse files
committed
New logging behavior
1 parent 44d20ab commit af1d52a

1 file changed

Lines changed: 33 additions & 29 deletions

File tree

docs/troubleshooting/debugging.mdx

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,36 @@ Find or configure application logs to find runtime issues.
44

55
All parts of Velopack have logging built in to help troubleshoot issues, and you should provide these logs when opening a GitHub issue about a potential bug.
66

7-
## Logging UpdateManager
8-
You can provide your own instance of `Velopack.Logging.IVelopackLogger` to `VelopackApp.SetLogger(IVelopackLogger)`. A logger can also be provided to the `UpdateManager` via its `IVelopackLocator``Log` property. The built-in locators support passing in an `IVelopackLocator` instance to their constructors.
9-
You cna also create a default locator using the `Velopack.Locators.VelopackLocator.CreateDefaultForPlatform(ILogger)` method.
7+
## Logging in Velopack
8+
9+
All Velopack components (binaries, libraries, and the UpdateManager) log to a shared file by default. The log file name includes the app ID from `sq.version` when available (e.g. `velopack_myapp.log`), or falls back to `velopack.log` when no app context exists (such as during initial setup/install). Log files are automatically rotated at 1 MB.
10+
11+
For the Update.exe and Setup.exe binaries, you can override the log location with the `--log {path}` parameter. You can also use the `--verbose` flag to capture debug/trace output to the log file.
12+
Please see the [command line reference](../reference/cli) for a comprehensive list of arguments supported.
13+
14+
### Windows
15+
- **Default**: `%LocalAppData%\velopack\velopack_{appid}.log`
16+
- **Setup.exe**: `%LocalAppData%\velopack\velopack.log` (no app context at install time)
17+
- **Fallback**: If `%LocalAppData%` is not accessible, logs are written to the system temp directory.
18+
19+
On Windows, to avoid showing up as a console window, the Velopack binaries are compiled as a WinExe and there will be no console output by default.
20+
21+
### Linux
22+
All logs will be sent to `/tmp/velopack_{appid}.log` (or `/tmp/velopack.log` without app context).
23+
24+
### macOS
25+
Logs are sent to `~/Library/Logs/velopack_{appid}.log`. If `~/Library/Logs` does not exist, falls back to `/tmp/velopack_{appid}.log`.
26+
27+
## Advanced Log Handling
28+
By default, the C# library logs to the same file as the Velopack binaries. You can provide an additional custom logger via `VelopackApp.SetLogger(IVelopackLogger)` — this will receive all diagnostic messages **in addition to** the default file log. A logger can also be provided to the `UpdateManager` via its `IVelopackLocator` `Log` property.
29+
30+
Note: If you provide a custom locator, the logger passed to `SetLogger` will be ignored — attach your logger to the custom locator instead.
31+
1032
For example:
1133
```cs
34+
using Velopack.Logging;
1235

13-
// ...
14-
15-
public class ConsoleVelopackLogger : IVelopackLogger
36+
public class MyConsoleLogger : IVelopackLogger
1637
{
1738
public void Log(VelopackLogLevel logLevel, string? message, Exception? exception)
1839
{
@@ -25,36 +46,19 @@ public class ConsoleVelopackLogger : IVelopackLogger
2546
}
2647
}
2748

28-
// ...
29-
using Velopack.Logging;
30-
49+
// Option 1: Pass to VelopackApp (used alongside default file logger)
3150
VelopackApp.Build()
32-
.SetLogger(new ConsoleVelopackLogger())
51+
.SetLogger(new MyConsoleLogger())
3352
.Run();
3453

35-
// ...
36-
using Velopack.Locators;
37-
using Velopack.Logging;
38-
39-
var locator = VelopackLocator.CreateDefaultForPlatform(new ConsoleVelopackLogger());
54+
// Option 2: Pass to a custom locator
55+
var locator = VelopackLocator.CreateDefaultForPlatform(new MyConsoleLogger());
4056
var updateManager = new UpdateManager("your-update-url", null, locator);
4157
```
4258

43-
## Logging in the Velopack binaries
44-
45-
### Windows
46-
Running Update.exe will log most output to it's base directory as `Velopack.log`. Setup.exe will not log to file by default. However, you can override the log location for both binaries with the `--log {path}` parameter. You can also use the `--verbose` flag to capture debug/trace output to log. Unfortunately, on Windows, to avoid showing up as a console window, these binaries are compiled as a WinExe and there will be no console output by default.
47-
Please see the [command line reference](../reference/cli) for a comprehensive list of arguments supported.
48-
49-
### Linux
50-
All logs will be sent to `/tmp/velopack.log`.
51-
52-
### MacOS
53-
Logs will be sent to `/tmp/velopack.log` or `~Library/Logs/velopack.log` depending on your version of Velopack.
54-
5559
## Advanced Debugging
56-
The debug builds of Velopack binaries have additional logging/debugging capabilities, and will produce console output. In some instances, it may be useful to [compile Velopack](../contributing/compiling.mdx) for your platform, and replace the release binaries of Setup.exe and Update.exe with debug versions.
60+
The debug builds of Velopack binaries have additional logging/debugging capabilities, and will produce console output. In some instances, it may be useful to [compile Velopack](../contributing/compiling.mdx) for your platform, and replace the release binaries of Setup.exe and Update.exe with debug versions.
5761

5862
If your issue is with package building, after building the rust binaries in Debug mode, it can also be useful to run the Velopack.Vpk project from Visual Studio with your intended command line arguments rather than running the `vpk` tool directly.
5963

60-
If doing this has not helped, you may need to debug and step through the rust binaries - for which I recommend the CodeLLDB VSCode extension.
64+
If doing this has not helped, you may need to debug and step through the rust binaries - for which I recommend the CodeLLDB VSCode extension.

0 commit comments

Comments
 (0)