Brobot Logging System
Transparent, Configuration-Driven Loggingโ
The Brobot framework provides built-in logging capabilities. For find() operations, logging happens automatically. For other actions (click(), type(), move(), etc.), you can add custom log messages via ActionConfig methods to provide context about what your automation is doing.
Key Principle: Logging is a cross-cutting concern that should be transparent to your automation code. You write normal automation logic, and Brobot handles the logging based on your configuration.
Current Status: Automatic logging without custom messages is fully implemented for Find operations. Other actions require custom log messages via withBeforeActionLog(), withSuccessLog(), and withFailureLog() methods.
Core Conceptsโ
Log Levelsโ
Brobot uses industry-standard SLF4J with Logback log levels:
- OFF - No logging
- ERROR - Error conditions requiring attention
- WARN - Warning conditions and potential issues
- INFO - Key business events and action results
- DEBUG - Detailed debugging information
- TRACE - Most detailed information including method entry/exit
Log Categoriesโ
Different aspects of automation are organized into categories:
- ACTIONS - User actions (click, type, find)
- TRANSITIONS - State transitions and navigation
- MATCHING - Pattern matching details
- PERFORMANCE - Timing and performance metrics
- STATE - State management events
- LIFECYCLE - Application lifecycle events
- VALIDATION - Input validation and checks
- SYSTEM - System-level events
- EXECUTION - Execution control events (pause, resume, stop)
Custom Log Messagesโ
Add custom log messages directly to your action configurations:
import io.github.jspinak.brobot.action.Action;
import io.github.jspinak.brobot.action.basic.find.PatternFindOptions;
import io.github.jspinak.brobot.model.state.StateImage;
import io.github.jspinak.brobot.action.report.ActionResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class LoginFlow {
@Autowired
private Action action;
public boolean findLoginButton(StateImage loginButton) {
// PatternFindOptions with custom logging
PatternFindOptions options = new PatternFindOptions.Builder()
.withBeforeActionLog("Searching for login button...")
.withSuccessLog("Login button found!")
.withFailureLog("Login button not found - check page state")
.setMaxSearchTime(5.0)
.setSimilarity(0.85)
.build();
// Perform find with custom logging
ActionResult result = action.perform(options, loginButton);
return result.isSuccess();
}
}
Note: The loginButton parameter is a StateImage object typically obtained from a @State class. See the Usage Guide for complete examples including State definitions.
Sample Outputโ
With transparent logging enabled, you'll see:
Standard actions (automatic logging only):
โ CLICK usernameField
โ CLICK usernameField | loc:(245,180) | sim:0.91 | 32ms
โ TYPE "user123"
โ TYPE "user123" | 125ms
โ CLICK loginButton
โ CLICK loginButton | loc:(520,380) | sim:0.92 | 45ms
With custom messages:
Searching for login button...
โ FIND loginButton
โ FIND loginButton | loc:(520,380) | sim:0.92 | 45ms
Login button found!
Failed action:
โ CLICK submitButton
โ CLICK submitButton | NOT FOUND | 5003ms
Documentation Structureโ
Logging System Guidesโ
- Configuration Guide - Detailed configuration options and property reference
- Usage Guide - How to use logging in your code with examples
- Output Formats - Available output formats (SIMPLE, STRUCTURED, JSON)
- Performance - Performance considerations and optimizations
Key Featuresโ
- Transparent Logging - No code changes needed, just configuration
- Configuration-Driven - Control everything via application.properties
- Hierarchical Configuration - Global settings cascade to specific categories
- Custom Messages - Add context with ActionConfig logging methods
- Session Management - Track workflows with ActionSessionManager
- Visual Indicators - Clear symbols (โ โ โ) for action status
- Concise Format - One-line summaries with essential information
- Multiple Output Formats - SIMPLE, STRUCTURED, and JSON
- Performance Optimized - Minimal overhead with early filtering
- No Special Services - Just use the standard Action class
Related Documentationโ
Configuration & Setupโ
- BrobotProperties Usage Guide - How to access logging properties in code
- Properties Reference - Complete reference for all Brobot properties
- Auto-Configuration Guide - Spring Boot auto-configuration
- Headless Configuration - Logging in headless/CI environments
- Initial States Configuration - Startup logging configuration
Testing & Debuggingโ
- Mock Mode Guide - Testing with logging in mock mode
- Profile-Based Testing - Using profiles to configure logging levels
- Integration Testing - Testing with logging enabled
- Action Recording - Recording actions with ActionHistory
- Image Find Debugging - Comprehensive debugging system
Core Library & Actionsโ
- ActionConfig Overview - Using custom logging methods (
withBeforeActionLog,withSuccessLog,withFailureLog) - ActionConfig Examples - Examples of ActionConfig with logging
- Convenience Methods - Action class convenience methods with automatic logging
- Quick Start Guide - Getting started with Brobot
- AI Project Creation Guide - Complete guide with logging best practices