[8.14](backport #4846) [windows] if elastic-agent run
fails, log error to Application EventLog
#4919
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
On Windows if the run command fails, then the error message will be sent to the Application EventLog. Other OSes do not require this since they capture stderr from processes that run as services, Windows does not.
This is only for the
run
command because the other commands should be run from the CLI, where the error is already published on stderr.Why is it important?
If any error happens before the elastic-agent internal logging is setup and the run command exits while running as a Windows service, the error is lost. Without this error it is very difficult to determine why
elastic-agent run
is failing.Checklist
./changelog/fragments
using the changelog toolDisruptive User Impact
How to test this PR locally
elastic-agent
with-a
flag pointing to CA certificates on the local filesystemelastic-agent
serviceelastic-agent
serviceRelated issues
Questions to ask yourself
Screenshots
This is an automatic backport of pull request #4846 done by [Mergify](https://mergify.com).