The Nethack log file - in my case, /var/games/nethack/logfile - has every game in chronological order. The following describes the format. Example:

3.3.1 19077 2 5 9 -1 87 1 20010828 20010509 501 Sam Hum Mal Law Weiforu,killed by an owlbear

Where the values are:

  1. Program version (important because some versions have different log formats; This describes 3.3.x and later log format. One important thing to note is that the 3.2.2 and earlier had different date formats and were not Y2K compliant.)
  2. Score
  3. Dungeon branch
  4. Dungeon level
  5. Maximum dungeon level
  6. Hit points
  7. Maximum hit points
  8. Number of deaths
  9. Date of death/ascension/escape/whatever
  10. Date of game start
  11. uid of the user who played that game
  12. Character class
  13. Race
  14. Gender
  15. Alignment
  16. Name
  17. What really happened

The dungeon branches:

Special endgame levels:

Dates (in post-3.3.x, at least) are in YYYYMMDD format.

(The information can be found from the Nethack source code, of course, but when finding out the information for this writeup and experimenting with the parsing myself (this turned into one monstrously big but well-working Java app), Jukka Lahtinen's small C program for analyzing logfiles helped somewhat...)