DIY custom logfile, noob version (help, please!)

HA, by itself, does this nice “protocol” of triggered switches, see example:

info

I would like to have exactly that information stored in a txt file, ideally only a limited number of entries.

I understand that I somehow need to have a triggered automation that watches the switch somehow, but I really, really need an explanation how to generate exactly the line that HA auto-generates itself (and write that into a txt file).

I understand I start with:

notify:
  - platform: file
    name: switchlog1
    filename: switchlog1.txt
    timestamp: False

in my config.yaml. And then what?