how to log the search history in mac dictionary
The following AppleScript code can be used in an Run AppleScript action as an Automator Service, and assigned a keyboard shortcut to act on a selected word to open it in the Dictionary, and log it, if it isn't already in the log file.

on run {input, parameters}
    try
        considering diacriticals
            if first character of (input as text) is not in "abcdefghijklmnopqrstuvwxyz" then
                tell current application
                    activate
                    display dialog "The selected text starts with a non-valid character." &amp; return &amp; return &amp; ¬
                        "Make a different selection and try again." buttons {"OK"} default button 1 ¬
                        with title "Dictionary Look Up Logging Service"
                end tell
                return
            end if
        end considering
        open location "dict://" &amp; input
        set theDictionaryHistoryFilename to "Dictionary Look Up Service History Log File.txt"
        set theTargetFilename to quoted form of (POSIX path of (path to documents folder as string) &amp; theDictionaryHistoryFilename)
        set foundSelectedWord to (do shell script "grep '^" &amp; input &amp; "$' " &amp; theTargetFilename &amp; " &gt; /dev/null; echo $?") as integer
        if foundSelectedWord is greater than 0 then
            do shell script "echo \"" &amp; input &amp; "\" &gt;&gt; " &amp; theTargetFilename
        end if
    end try
end run


Note that if the log file is open when the service is run, the added word may not appear until you close and reopen the log file, depending on what app you have the log file open in.