digital-asset / daml

The Daml smart contract language
https://www.digitalasset.com/developers
797 stars 201 forks source link

Include dates in JSON API logs #9979

Closed cocreature closed 3 years ago

cocreature commented 3 years ago

If you have multi-day logs times are insufficient.

realvictorprm commented 3 years ago

valid point, I thought they are included by default :facepalm: I'll fix that.

realvictorprm commented 3 years ago

@cocreature do you think statements like this would be better?

2021-06-14 13:12:56.698 [http-json-ledger-api-akka.actor.default-dispatcher-9] INFO  com.daml.http.HttpService - HTTP Server pre-startup , context: {instance_uuid=8e6043de-b004-4630-93c6-7355d15d48a8} 
2021-06-14 13:12:56.928 [http-json-ledger-api-akka.actor.default-dispatcher-9] INFO  com.daml.http.LedgerClient$ - Attempting to connect to the ledger localhost:6865
 (attempt 1/600)  
2021-06-14 13:12:58.470 [timer-utils] INFO  com.daml.http.LedgerClient$ - Attempting to connect to the ledger localhost:6865
 (attempt 2/600)  
2021-06-14 13:12:59.474 [timer-utils] INFO  com.daml.http.LedgerClient$ - Attempting to connect to the ledger localhost:6865
 (attempt 3/600)  
2021-06-14 13:13:00.478 [timer-utils] INFO  com.daml.http.LedgerClient$ - Attempting to connect to the ledger localhost:6865
realvictorprm commented 3 years ago

With the log encoder being json it currently looks like this:

{"@timestamp":"2021-06-14T13:14:47.807+02:00","@version":"1","message":"Attempting to connect to the ledger localhost:6865\n (attempt 19/600)","logger_name":"com.daml.http.LedgerClient$","thread_name":"timer-utils","level":"INFO","level_value":20000}
{"@timestamp":"2021-06-14T13:14:48.809+02:00","@version":"1","message":"Attempting to connect to the ledger localhost:6865\n (attempt 20/600)","logger_name":"com.daml.http.LedgerClient$","thread_name":"timer-utils","level":"INFO","level_value":20000}
{"@timestamp":"2021-06-14T13:14:49.811+02:00","@version":"1","message":"Attempting to connect to the ledger localhost:6865\n (attempt 21/600)","logger_name":"com.daml.http.LedgerClient$","thread_name":"timer-utils","level":"INFO","level_value":20000}
cocreature commented 3 years ago

From a quick look, we log with %date{"dd-MM-yyyy HH:mm:ss.SSS", UTC} in other places which seems pretty close to what you’re suggesting. I’d just use the same. Using different logging styles between different apps isn’t helpful to anyone.

realvictorprm commented 3 years ago

Then we'll go with %date{"dd-MM-yyyy HH:mm:ss.SSS", UTC} :)