I want to maintain a log of when the SD card is ejected or mounted in my Android device. How can I do this?
That could e.g. be done using tasker:
You will need a separate profile for each action (mount/eject) with the respective condition, but of course you can write to the same file (or use a separate one if you prefer).
For details on Tasker, please check with our tasker tag-wiki.