In our project we are using WSO2 API Manager v 2.1.0. Our goal is to write a fault sequence that will log some information in custom logfile, example timestamp, name of the API etc. I was able to create a file and write to it, but it does not work as expected. Things I need to have is
- Control the file name
- Append content to file instead of overwriting it each time
This is the sequence I am using (simplified easier reading):
<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="admin--FaultyAPI2:v1.0.0--Fault">
<clone continueParent="true">
<target>
<sequence>
<property xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:ns3="http://org.apache.synapse/xsd" name="destination" expression="get-property('To')"/>
<format>
{
"destination_host" : "$1"
}
</format>
<args>
<arg xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:ns3="http://org.apache.synapse/xsd" evaluator="xml" expression="get-property('destination')"/>
</args>
</payloadFactory>
<property name="transport.vfs.ReplyFileName" value="test.txt" scope="transport" type="STRING"/>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<send>
<endpoint>
<http uri-template="vfs:file:///home/install/out?transport.vfs.Append=true"/>
</endpoint>
</send>
</sequence>
</target>
</clone>
</sequence>
Following documentation I have used transport.vfs.ReplyFileName
to specify the file name and ?transport.vfs.Append=true
path parameter to tell it to append to file. The problem is that those two things are ignored.
First thing is that the file created is not test.txt
but it is the endpoint URI that failed (the one I have setup in API Manager). So if I call /fault
endpoint the file created is fault
under location specified.
The second thing is that it is not appending to a file, but overwriting it each time the sequence is triggered. It is even worse! It creates actual path /home/install/out?transport.vfs.Append=true
on file system and saves the file under this directory.
Those features seems to work under WSO ESB, but not API Manager. Any ideas anyone?