All Macros Updated in this thread in line with comments.
We have:
M1002.txt which is the most basic logging macro, it logs what date and time a gcode file was run
M1003,txt which is the next step up for logging when a file was loaded and when that file was run.
M1004.txt logs when which and when a gcode file was loaded, when the gcode file was run, stopped, feedhold was active, and when the gcode file ended (it requires you to copy and paste a short function within the M30 macro in order for the M1004 macro to log when the program completed) (included within the M1004 macro).
M1004 could be further modified (if you require) to save a file for each g-code file that is run to a location of your choosing (including a network address). PM me if you want me to do this for you as I'm sure you'd prefer them logged somewhere specific. This can also be setup to run each time you run the specific g-code file it saves the information to an individual file or it appends an existing file.
There are other options to log tool changes / what tools were used, what the set feedrate was at different times, what the linear error settings were etc etc. Basically most things can be logged if you advise what you want, in what format and where you want it to go.