Encode Logs to JSON for Saving