Message Logging - Does not log when one of the variables used is not resolvable

Not applicable

Hi,

I have used MessageLogging Policy in my PostClientFlow...Iam able to log during the happy path scenario where all the variables used are resolvable but not in an fault flow..

Scenario

I need to log the product name which is avalaible only after verifyAPI policy...but when verifyApi policy fails the productName is not resolvable , hence no logging is done

Can you let me know how to resolve

Thanks

MessageLogging Policy

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<MessageLogging async="false" continueOnError="true" enabled="true" name="MessageLogging.LogServiceCalls">
<DisplayName>MessageLogging.LogServiceCalls</DisplayName>
<File>
<Message defaultVariableValue="unknown">{organization.name}.{environment.name}.{apiproxy.name}.{api.product.name}
</Message>
<FileName>tApi.log</FileName>
<FileRotationOptions rotateFileOnStartup="true">
<FileRotationType>TIME_SIZE</FileRotationType>
<MaxFileSizeInMB>1024</MaxFileSizeInMB>
<MaxFilesToRetain>10</MaxFilesToRetain>
<!--<RotationFrequency unit="minute">600</RotationFrequency>-->
</FileRotationOptions>
</File>
<logLevel>ERROR</logLevel>
</MessageLogging>

0 2 314
2 REPLIES 2

Hi @Deepa. You can do one of two things to get logging to complete even if you can't get a product name (which you won't if Verify API Key fails).

<Message defaultVariableValue="unknown">

on the root element...

or

{apiproduct.name:unknown}

The first one prints out "unknown" if any variable is unresolved, and the second prints "unknown" if apiproduct.name doesn't resolve. This is described in the Message Logging policy doc.

You should also remove the period after "api" in your variable name. Should just be apiproduct.name.

As you can see in the code snippet I have used the defaultVariableName but that did not resolve the problem...

I don't see any errors the log file gets created but no logs are written

Thanks in advance