hi, you can save something to file with
/file set file_name.txt contents="Whatever you want to save to file $IncludingVariablesContents or $[/system clock get time]"
but you have to create this file at first and there is no /file add unfortunately. You can also set variable to contain return value of command, but it wont log whole command output.
:local pingVar [/ping 8.8.8.8 count=10]
this will return number of successful pings, but not whole ping command output.
The easiest way to get command output from mikrotik is using ssh. From linux or cygwin you can ssh to mikrotik device and redirect outpu to file.
ssh admin@1.2.3.4 ':put "$[/system clock get time], $[/system clock get date]";/tool traceroute address=8.8.8.8' >> mikrotik-log.txt
Run this from cron and it will append whole mikrotik commands output to file mikrotik-log.txt. First put will return time and date before traceroute output.