Capture and forward logs from your Tauri application to WebDriverIO's logger system.
The Tauri service can capture and forward logs from both the Rust backend and frontend console to WebDriverIO's logger system. This allows you to see Tauri application logs seamlessly integrated with your test output.
Log forwarding is disabled by default. Enable it via service options:
// wdio.conf.ts
export const config = {
services: [
['@wdio/tauri-service', {
// Enable backend log capture (Rust logs from stdout)
captureBackendLogs: true,
// Enable frontend log capture (console logs from webview)
captureFrontendLogs: true,
// Minimum log level for backend logs (default: 'info')
backendLogLevel: 'info',
// Minimum log level for frontend logs (default: 'info')
frontendLogLevel: 'info',
}],
],
capabilities: [
{
browserName: 'tauri',
'tauri:options': {
application: './path/to/app',
},
},
],
};Both backend and frontend log capture support the following log levels (in order of priority):
trace- Most verbosedebug- Debug informationinfo- Informational messages (default)warn- Warning messageserror- Error messages
Only logs at the configured level and above will be captured. For example, with backendLogLevel: 'info', only info, warn, and error logs will be captured.
Captured logs are formatted with context tags:
- Backend logs:
[Tauri:Backend] message - Frontend logs:
[Tauri:Frontend] message - Multiremote logs:
[Tauri:Backend:instanceId] messageor[Tauri:Frontend:instanceId] message
Backend log capture reads Rust logs from the Tauri application's stdout. These logs are generated using Rust's log crate:
// In your Tauri app
log::info!("This is an info log");
log::warn!("This is a warning");
log::error!("This is an error");The service automatically filters out tauri-driver logs and only captures logs from your Tauri application.
Frontend log capture uses WebDriver's getLogs API to retrieve console logs from the webview:
// In your Tauri app frontend
console.info('This is an info log');
console.warn('This is a warning');
console.error('This is an error');Frontend logs are captured periodically (every second) and before each WebDriver command to ensure all logs are captured.
Backend and frontend log capture can be configured independently:
services: [
['@wdio/tauri-service', {
// Only capture backend logs
captureBackendLogs: true,
captureFrontendLogs: false,
backendLogLevel: 'debug', // Capture debug and above
}],
],In multiremote scenarios, logs are captured per instance with instance IDs in the log context:
capabilities: {
browserA: {
browserName: 'tauri',
'tauri:options': {
application: './path/to/app',
},
},
browserB: {
browserName: 'tauri',
'tauri:options': {
application: './path/to/app',
},
},
},
services: [
['@wdio/tauri-service', {
captureBackendLogs: true,
captureFrontendLogs: true,
}],
],Logs will appear as:
[Tauri:Backend:browserA] message[Tauri:Frontend:browserB] message
- Log capture is optional and disabled by default to avoid overhead
- Frontend log capture uses periodic polling (every 1 second) which has minimal performance impact
- Backend log parsing is efficient and non-blocking
- Log level filtering reduces the number of logs processed
- Ensure
captureBackendLogsorcaptureFrontendLogsis set totrue - Check that your log level is appropriate (logs below the configured level won't appear)
- Verify logs are being written to stdout (backend) or console (frontend)
- Increase the log level (e.g., from
debugtoinfo) to filter out verbose logs - Disable log capture for one source if you only need backend or frontend logs
- Some WebDriver implementations may not support
getLogsAPI - The service will silently fail if
getLogsis not supported - Backend logs will still work in this case
- Configuration for all service options
- Usage Examples for logging patterns
- Troubleshooting for common issues