Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

MessageLogging policy fails to write logs to cloud logging- logging failure action detection

I have a MessageLogging policy in Post client flow for logging request ,response, policy executed flags variables and so on 
I do not use any javascript policies to set these variables anywhere. for some reason if any of those variables fails to be set ( "developerEmail": "{escapeJSON(developer.email)}",)  the MessageLogging policy Does not throw an error in the debugging session ,does not set any error variables . it also does not write this log to cloud logging.
Is there a way to detect if the message logging action it self  failed (writing those logs not the policy itself because according to the documentation the policy itself succeeds even if logging fails)   for me to take a decision in my proxy accordingly like to log this failure or so ??

dareenhamdy_0-1736699638067.png

https://cloud.google.com/apigee/docs/api-platform/reference/policies/message-logging-policy#fault-va...

 

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<MessageLogging continueOnError="false" enabled="true" name="ML-LogSuccessRequestToCloudLogs">
  <DisplayName>ML-LogSuccessRequestToCloudLogs</DisplayName>
  <CloudLogging>
    <LogName>projects/{projectId}/logs/{apiproxy.name}</LogName>
    <Message contentType="application/json">
      {
        "proxyGeneralInfo": {
            "environmentName": "{environment.name}",
            "apiProxyName": "{apiproxy.name}",
            "apiProxyRevision": "{apiproxy.revision}",
            "apiProductName": "{apiproduct.name}",
            "appName": "{developer.app.name}",
            "clientId": "{client_id}",
            "correlationId": "{messageid}",
            "developerEmail": "{escapeJSON(developer.email)}",
            "callingIPAddress": "{escapeJSON(client.ip)}"
        },
        "requestInfo":{
          "requestUrl": "{request.url}",
          "verb": "{request.verb}",
          "requestReceivedAt": "{client.received.end.time}",
          "requestFormParameters": "{request.formstring}",
          "requestHeaderNames":"{request.headers.names.string}",
          "requestQueryParameters": "{request.querystring}",
          "requestPayload": "{escapeJSON(request.content)}",
          "originalServerResponse":"{escapeJSON(original-server-response)}"
        },
        "responseInfo":{
          "responseStatusCode": "{message.status.code}",
          "responseHeaders":"{message.headers.names.string}",
          "responseSentAt": "{client.sent.end.time}",
          "responsePayload": "{escapeJSON(message.content)}",
          "originalServerResponse":"{escapeJSON(original-server-response)}"
        },
        "proxyExecutedPolicies":{
          "OAuthV2-ValidateAuthToken":{
            "failed":"{oauthV2.OAuthV2-ValidateAuthToken.failed}"
          },
          "SA-ApplySpikeArrest":{
            "failed":"{ratelimit.SA-ApplySpikeArrest.failed}"
          }
        }
      }
    </Message>
    <ResourceType>api</ResourceType>
  </CloudLogging>
  <logLevel>INFO</logLevel>
</MessageLogging>
0 3 335
3 REPLIES 3