Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.
Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

MessageLogging timestamp format

Hi,

When working with the MessageLogging policy, how do you change the timestamp format to for example YYYY-MM-DD etc..instead of this: "system.timestamp":"1532413540669" ?

So far by reading the documentation I have not found this setting.

This is what I have in my policy:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<MessageLogging async="false" continueOnError="false" enabled="true" name="Message-Logging-1">
    <DisplayName>Message Logging-1</DisplayName>
    <File>
        <Message>
            {
                "system.timestamp":"{system.timestamp}",
                "environment.name":"{environment.name}",
                "apiproxy.name":"{apiproxy.name}",
                "apiproxy.revision":"{apiproxy.revision}",
                "proxy.pathsuffix":"{proxy.pathsuffix}",
                "apigee.apiproduct.name":"{apigee.apiproduct.name}",
                "apigee.client_id":"{apigee.client_id}",
                "apigee.developer.app.name":"{apigee.developer.app.name}",
                "request.header.X-Forwarded-For":"{request.header.X-Forwarded-For}",
                "request.verb":"{request.verb}",
                "log.uuid":"{messageid}",
                "client.received.start.timestamp":"{client.received.start.timestamp}",
                "client.sent.end.timestamp":"{client.sent.end.timestamp}",
                "target.sent.start.timestamp":"{target.sent.start.timestamp}",
                "target.received.end.timestamp":"{target.received.end.timestamp}",
                "request.uri":"{request.uri}",
                "request.querystring":"{request.querystring}",
                "target.url":"{target.url}",
                "target.request.url":"{request.url}",
                "target.received.content.length":"{target.received.content.length}",
                "message.status.code":"{message.status.code}",
                "response.status.code":"{response.status.code}",
                "request.header.Accept":"{request.header.Accept}",
                "proxy.basepath":"{proxy.basepath}",
                "response_reason_phrase":"{message.reason.phrase}",
                "organization.name":"{organization.name}",
                "virtualhost.name":"{virtualhost.name}",
                "request.header.host":"{request.header.host}",
                "error.state":"{error.state}" 
            }
        
        </Message>
        <FileName>test2.log</FileName>
        <FileRotationOptions rotateLogFileOnStartup="false">
            <FileRotationType>TIME_SIZE</FileRotationType>
            <MaxFileSizeInMB>512</MaxFileSizeInMB>
            <MaxFilesToRetain>1</MaxFilesToRetain>
            <RotationFrequency unit="day">1</RotationFrequency>
        </FileRotationOptions>
    </File>
    <BufferMessage>true</BufferMessage>
    <logLevel>ERROR</logLevel>
</MessageLogging>
Solved Solved
0 3 2,478
1 ACCEPTED SOLUTION

This, sort of works:

"date/time":"{system.time.year}-{system.time.month}-{system.time.day} {system.time.hour}:{system.time.minute}:{system.time.second}" 

But for some reason the time ends up looking like this:

 "date/time":"2018-7-24 8:0:54",

View solution in original post

3 REPLIES 3