Comprehensive debug logging has been added to track whether the Prolog server is running the scheduling algorithms or if the system is falling back to C# implementations.
All debug logs related to Prolog scheduling use specific prefixes for easy filtering:
- [SCHEDULER-DEBUG] - BackendService SchedulingService logs
- [PROLOG-IMPL] - PrologSchedulerImpl initialization and setup
- [PROLOG-EXEC] - Actual Prolog execution (calls to HTTP service)
- [PROLOG-SUCCESS] - Successful Prolog execution
- [PROLOG-WARNING] - Prolog warnings (no results, invalid format)
- [PROLOG-FALLBACK] - Fallback to C# implementation
- [PROLOG-FALLBACK-EDT] - EDT algorithm fallback
- [PROLOG-FALLBACK-GENETIC] - Genetic algorithm fallback
- [PROLOG-FALLBACK-GREEDY] - Greedy heuristic fallback
- [OEM-SCHEDULING] - OEMService scheduling calls
- [OEM-SCHEDULING-ERROR] - OEMService error handling
- [OPERATION-PLAN] - Operation plan generation tracking
OperationPlanService.GenerateAsync()
└─> [OPERATION-PLAN] SchedulingServiceClient called with date and algorithm
└─> SchedulingServiceClient.GenerateDailyScheduleAsync()
└─> [OEM-SCHEDULING] HTTP request to BackendService
SchedulingService.ComputeDailyScheduleAsync()
└─> [SCHEDULER-DEBUG] Service entry point
- Scheduler Implementation type (PrologSchedulerImpl)
- Resource counts (visits, docks, cranes, staff, storage)
- Algorithm requested
└─> PrologScheduler.ComputeDailySchedule()
└─> [PROLOG-IMPL] Implementation initialization
- Resource availability checks
- Job mapping
└─> ComputeSequenceAsync()
└─> [PROLOG-EXEC] Prolog execution attempt
- Algorithm and vessel count
- Prolog program size
- Goal being executed
✓ SUCCESS:
└─> [PROLOG-SUCCESS] JSON response parsed
└─> Return scheduled operations
✗ FAILURE:
└─> [PROLOG-FALLBACK] Exception caught
├─> [PROLOG-FALLBACK-EDT] EDT algorithm fallback
├─> [PROLOG-FALLBACK-GENETIC] Genetic fallback
└─> [PROLOG-FALLBACK-GREEDY] Greedy fallback
└─> Return C# computed schedule
[PROLOG-EXEC] Starting Prolog computation. Algorithm: minimize-delay, Vessels: 3, Cranes: 2
[PROLOG-EXEC] Calling Prolog with goal: run_scheduler. Program length: 1245 chars
[PROLOG-EXEC] Prolog query returned 1 solutions
[PROLOG-SUCCESS] Successfully parsed Prolog JSON response
[SCHEDULER-DEBUG] ComputeDailyScheduleAsync completed. Algorithm Used: prolog:minimize-delay...
[PROLOG-EXEC] Starting Prolog computation. Algorithm: minimize-delay, Vessels: 2, Cranes: 1
[PROLOG-EXEC] Calling Prolog with goal: run_scheduler. Program length: 890 chars
[PROLOG-FALLBACK] Prolog scheduler error, falling back to Greedy heuristic
[PROLOG-FALLBACK-GREEDY] Using Greedy heuristic fallback for minimize-delay
[SCHEDULER-DEBUG] ComputeDailyScheduleAsync completed. Algorithm Used: prolog:minimize-delay...
The algorithm field returned in the schedule response indicates:
- prolog:minimize-delay - Prolog minimize-delay algorithm was used
- prolog:edt - Prolog Early Departure Time algorithm was used
- prolog:genetic - Prolog Genetic algorithm was used
- prolog-stub:* - C# stub was used (if registered instead of impl)
When investigating scheduling issues:
-
Is Prolog executing?
- Look for
[PROLOG-EXEC]logs - Check if
[PROLOG-SUCCESS]appears after execution - If you see
[PROLOG-FALLBACK], Prolog failed
- Look for
-
What error occurred?
- Check the exception message in
[PROLOG-FALLBACK]logs - Review
[PROLOG-WARNING]for JSON parsing issues - Look for HTTP connection errors in
[OEM-SCHEDULING-ERROR]
- Check the exception message in
-
Resource availability
- Check
[PROLOG-IMPL]logs for resource warnings - Verify vessel counts match expected data
- Confirm all dependencies available (docks, cranes, staff, storage)
- Check
-
Performance metrics
- Note the Prolog program size (
Program length) - Track execution time between
[PROLOG-EXEC]start and result - Compare algorithm used vs requested
- Note the Prolog program size (
{
"Logging": {
"LogLevel": {
"PortLogistics.Application.Backend.Domain.Scheduling.SchedulingService": "Information",
"PortLogistics.Application.Backend.Infrastructure.Scheduling.PrologSchedulerImpl": "Information",
"Default": "Information"
}
}
}{
"Logging": {
"LogLevel": {
"OEMService.Services.SchedulingServiceClient": "Information",
"OEMService.Domain.OperationPlans.OperationPlanService": "Information",
"Default": "Information"
}
}
}Complete execution trace with all logs:
[OPERATION-PLAN] Schedule received from backend. Algorithm: prolog:minimize-delay, Feasible: true, Operations: 5, TotalDelay: 120
[SCHEDULER-DEBUG] ComputeDailyScheduleAsync completed. Algorithm Used: prolog:minimize-delay, Feasible: true, Operations Scheduled: 5, Total Delay Minutes: 120, Warnings: 0
[PROLOG-SUCCESS] Successfully parsed Prolog JSON response
[PROLOG-EXEC] Prolog query returned 1 solutions
[PROLOG-EXEC] Calling Prolog with goal: run_scheduler. Program length: 2156 chars
[PROLOG-EXEC] Starting Prolog computation. Algorithm: minimize-delay, Vessels: 5, Cranes: 3
[PROLOG-IMPL] ComputeDailySchedule completed. Schedule generated with 5 scheduled operations
[PROLOG-IMPL] ComputeDailyScheduleAsync called. Scheduler Implementation: PrologSchedulerImpl, TargetDate: 2025-12-31, Algorithm: minimize-delay, Active Visits: 5, Docks: 2, Cranes: 3, Staff: 4, Storage Areas: 2
[SCHEDULER-DEBUG] ComputeDailyScheduleAsync called. Scheduler Implementation: PrologSchedulerImpl, TargetDate: 2025-12-31, Algorithm: minimize-delay, Active Visits: 5, Docks: 2, Cranes: 3, Staff: 4, Storage Areas: 2
[OEM-SCHEDULING] Successfully received daily schedule. Algorithm: prolog:minimize-delay, Operations: 5, Feasible: true, TotalDelay: 120 minutes
[OEM-SCHEDULING] BackendService responded with status 200
[OEM-SCHEDULING] Calling BackendService to generate daily schedule. TargetDate: 2025-12-31, Algorithm: minimize-delay
- Look for HTTP exceptions in
[OEM-SCHEDULING-ERROR]or[PROLOG-EXEC] - Check Prolog service logs for errors
- Verify network connectivity:
docker logs prolog
- Check if Prolog service is running
- Verify Prolog configuration in appsettings (Base URL, port)
- Review exception messages in
[PROLOG-FALLBACK]logs - Check Prolog program syntax in logs
- Verify request algorithm parameter matches what's logged
- Check if algorithm is supported by Prolog service
- Review
[SCHEDULER-DEBUG]for which scheduler implementation is registered
Application/BackendService/Domain/Scheduling/SchedulingService.csApplication/BackendService/Infrastructure/Scheduling/PrologSchedulerImpl.csApplication/OEMService/Services/SchedulingServiceClient.csApplication/OEMService/Domain/OperationPlans/OperationPlanService.cs
To switch between real Prolog and C# stub, modify Startup.cs:
// For real Prolog:
services.AddSingleton<IPrologScheduler, PrologSchedulerImpl>();
// For C# stub (testing without Prolog service):
services.AddSingleton<IPrologScheduler, PrologSchedulerStub>();Currently registered: PrologSchedulerImpl (real Prolog)