Issue Logging API Response from State Machine to CloudWatch

emanuel.dajti
emanuel.dajti Software Developer Spryker Technology Partner Posts: 2 🧑🏻‍🚀 - Cadet

Hello Team,

We have several APIs integrated and are using Spryker\Shared\Log\LoggerTrait to log request and response payloads to AWS CloudWatch. While logging works as expected for Yves and Backgw with the same configuration, we are unable to see the logs for the state machine.

For example, we are using the following code to log the response:

$this->getLogger()->info(json_encode(response));

Despite this, the logs are not appearing in CloudWatch for the state machine, though they do appear for the shop.

Has anyone encountered this issue when trying to log API request/response for state machine? Any advice on how to resolve this would be greatly appreciated.

Thank you in advance for your help!

Best regards,

Emanuel

Answers

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,095 ⚖️ - Guardians (admin)

    Heyhey @emanuel.dajti ,

    interesting question! When you talk about the State Machine you mean in general tasks which are executed in the background by jenkins, right? Because most of the OMS is done async via background tasks.

    Based on my latest information jenkins is not logging to cloudwatch. Only way to see exceptions or any output is though the Jenkins UI.

    All the best,

    Florian

  • emanuel.dajti
    emanuel.dajti Software Developer Spryker Technology Partner Posts: 2 🧑🏻‍🚀 - Cadet

    Hi @fsmeier

    Thank you for your response. When I referred to the state machine, I meant the general tasks(jobs) running in the background on Jenkins—sorry for not pointing that out. We’ve actually found a way (in collaboration with Spryker colleague) to make the logs visible both in Jenkins and CloudWatch.

    How this works is like following:

    Scheduled jobs are wrapped by a script ( loggable.sh ). This wrapper script creates two temporary pipes which are responsible for also writing to /proc/1/fd/{1,2}, where the Cloudwatch log collector is collecting data from.

    Best regards,

    Emanuel