logLevel in MessageLogging is not working as expected due to some reason.

Hello,

I may need a help to identify what wrong I am doing here....

Given logLevel is ERROR, but it is logging all the success and failure. Not sure what is wrong here in the Message Logging code. Also, tried the other valid values (ALERT, WARN) but I don't see any difference - all the success and failures are logging. (I am not using FormatMessage here).

What I am trying to do is, log only the failed transactions (such as the response code with 4XX, 5XX).

Apigee Version 4.18.05.00

Any input on this is appreciated..

Post Client Flow code:

<PostClientFlow> <Request/> <Response> <Step> <Name>Message-Logging</Name> </Step> </Response> </PostClientFlow>

Message Logging Code:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<MessageLogging async="false" continueOnError="false" enabled="true" name="Message-Logging">

<logLevel>ERROR</logLevel>

<DisplayName>Message Logging</DisplayName>

<File>

<FileName>message.log</FileName>

<Message>

{ "date/time":"{system.time.year}-{system.time.month}-{system.time.day} {system.time.hour}:{system.time.minute}:{system.time.second}", "system.timestamp":"{system.timestamp}", "apiproxy.name":"{apiproxy.name}", "log.uuid":"{messageid}", "message.status.code":"{message.status.code}", "error.state":"{error.state}", "error.message":"{error.message}" }

</Message>

</File>

</MessageLogging>

0 1 122
1 REPLY 1

Hi @Shylendran

'logLevel' determines the log level that gets stored in the target log file. It has nothing to do with when the policy executes under what conditions.

If you only wanted the message to be logged when the target server returns 4xx or 5xx, then you should place the ML policy in the TargetEndpoint PreFlow Response flow like follows:

<TargetEndpoint name="default">
    <PreFlow name="PreFlow">
...
        <Response>
            <Step>
                <Name>LogErrorMessage</Name>
                <Condition>(response.status.code GreaterThanOrEquals "400")</Condition>
            </Step>
        </Response> 

Note, that MessageLogging policy will log asynchronously, so it's ok to have it outside of the PostClientFlow!