The service is seamlessly integrated with the Dictionary service on your Mac. It is even installed on the same keyboard shortcut: Command-Control-D.
The only limitation is that it only works with selected text, so if you are looking up a word by hovering the cursor over it, in, say, Preview or Safari, then you'll have to choose More in the lower right corner of the Dictionary sheet that pops up to view the full Dictionary window. Then you'll have to press Command-Control-D once more, to "log" the word into the text file (the search word turns up selected in the Dictionary window.)
Avoid the above limitation by selecting the word before Command-Control-D. If you select the word before pressing Command-Control-D, then everything is handled automatically.
Since English is not my native language, this is something I have been wanting for years. So it is mostly made for non-native English speaker, but may also be useful for native anglophones.
How to install:
Open Automator
Choose service and don't check anything
Search for the Run AppleScript action, and add it to your Service
Paste in the script below, replacing everything that is by default in the Run AppleScript action
Save the Service as dictLogger
Quit Automator
Open the Keyboard preferences of the System Preferences pane
Find the service under "Services" and install it with the keyboard shortcut Command-Control-D
After you have successfully looked up a word, look into the file "DictLogger.txt" that should be on your Desktop if everything is working
Select a word in "DictLogger.txt", to see that it works from here
If you use some app other than TextEdit for .txt files, be sure to set the default app of this file to TextEdit, if you want it to open with TextEdit. I don't guarantee that every other text editor will work, though I think it will work with TextWrangler and BBEdit
# © McUsr/MacUser06 2012
on run {input, parameters}
set glossaryName to "DictLogger.txt"
set AutomatorIcon to (a reference to file ((path to applications folder as text) & "Automator.app:Contents:Resources:Automator.icns"))
# checks to see if the current selection contains anything valid
considering diacriticals
if first character of (input as text) is not in "abcdefghijklmnopqrstuvwxyz" then
tell application "System Events" to set appname to name of first process whose frontmost is true
using terms from application "Finder"
tell application appname
display dialog "The selection you tried to look up a dictionary definiton for contains non-valid characters.
Please copy the selection you used into an empty text document to figure out what is wrong.
Quitting for now…" with title "Dictionary Logging Service" buttons {"Ok"} default button 1 with icon AutomatorIcon
end tell
end using terms from
return input
end if
end considering
try
open location "dict://" & input
end try
tell application "TextEdit"
try
set glossaryDoc to its document glossaryName
on error
set glossaryDoc to null
end try
end tell
try
set theF to quoted form of (POSIX path of (path to desktop folder as text) & glossaryName)
end try
set foundword to true
try
do shell script "test -f " & theF & " || touch " & theF
set foundword to (do shell script "grep '^" & input & "$' " & theF & ">/dev/null && echo \"true\" || echo \"false\"") as boolean
end try
if not foundword then
if glossaryDoc is not null then
tell application "TextEdit"
tell its document glossaryName
make new paragraph at beginning of its text with data ((input as text) & linefeed)
end tell
save glossaryDoc
end tell
else
try
do shell script "export TMPFILE=`mktemp /tmp/${tempfoo}.XXXXXX` && cat " & theF & " >$TMPFILE ; echo " & input & ">|" & theF & " ; cat $TMPFILE >>" & theF
end try
end if
end if
do shell script "open -b \"com.apple.Dictionary\""
return input
end run

