|
4 | 4 | using System.Management.Automation.Runspaces; |
5 | 5 | using System.Net; |
6 | 6 | using System.Security.Cryptography.X509Certificates; |
| 7 | +using Keyfactor.Logging; |
7 | 8 | using Keyfactor.Orchestrators.Common.Enums; |
8 | 9 | using Keyfactor.Orchestrators.Extensions; |
9 | 10 | using Microsoft.Extensions.Logging; |
@@ -140,13 +141,16 @@ private JobResult PerformRemoval(ManagementJobConfiguration config) |
140 | 141 | } |
141 | 142 | catch (Exception ex) |
142 | 143 | { |
143 | | - _logger.LogTrace(ex.Message); |
| 144 | + _logger.LogTrace(LogHandler.FlattenException(ex)); |
| 145 | + |
| 146 | + string failureMessage = $"Remove job failed for Site '{config.CertificateStoreDetails.StorePath}' on server '{config.CertificateStoreDetails.ClientMachine}' with error: '{ex.Message}'"; |
| 147 | + _logger.LogWarning(failureMessage); |
| 148 | + |
144 | 149 | return new JobResult |
145 | 150 | { |
146 | | - Result = OrchestratorJobStatusJobResult.Failure, |
| 151 | + Result = OrchestratorJobStatusJobResult.Failure, |
147 | 152 | JobHistoryId = config.JobHistoryId, |
148 | | - FailureMessage = |
149 | | - $"Site {config.CertificateStoreDetails.StorePath} on server {config.CertificateStoreDetails.ClientMachine}: {ex.Message}" |
| 153 | + FailureMessage = failureMessage |
150 | 154 | }; |
151 | 155 | } |
152 | 156 | } |
@@ -318,13 +322,16 @@ function InstallPfxToMachineStore([byte[]]$bytes, [string]$password, [string]$st |
318 | 322 | } |
319 | 323 | catch (Exception ex) |
320 | 324 | { |
321 | | - _logger.LogTrace(ex.Message); |
| 325 | + _logger.LogTrace(LogHandler.FlattenException(ex)); |
| 326 | + |
| 327 | + string failureMessage = $"Add job failed for Site '{config.CertificateStoreDetails.StorePath}' on server '{config.CertificateStoreDetails.ClientMachine}' with error: '{ex.Message}'"; |
| 328 | + _logger.LogWarning(failureMessage); |
| 329 | + |
322 | 330 | return new JobResult |
323 | 331 | { |
324 | 332 | Result = OrchestratorJobStatusJobResult.Failure, |
325 | 333 | JobHistoryId = config.JobHistoryId, |
326 | | - FailureMessage = |
327 | | - $"Site {config.CertificateStoreDetails.StorePath} on server {config.CertificateStoreDetails.ClientMachine}: {ex.Message}" |
| 334 | + FailureMessage = failureMessage |
328 | 335 | }; |
329 | 336 | } |
330 | 337 | } |
|
0 commit comments