Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should I write a user specific log file to (and be XDG base directory compatible)

Tags:

By default, pip logs errors into "~/.pip/pip.log". Pip has an option to change the log path, and I'd like to put the log file somewhere besides ~/.pip so as not to clutter up my home directory. Where should I put it and be XDG base dir compatible?

Right now I'm considering one of these:

  • $XDG_DATA_HOME (typically $HOME/.local/share)
  • $XDG_CACHE_HOME (typically $HOME/.cache)
like image 312
bwv549 Avatar asked Sep 17 '14 18:09

bwv549


1 Answers

This is, for the moment, unclear.

Different software seem to handle this in different ways (imsettings puts it in $XDG_CACHE_HOME, profanity in $XDG_DATA_HOME).

Debian, however, has a proposal which I can get behind (emphasis mine):

This is a recurring request/complaint (see this or this) on the xdg-freedesktop mailing list to introduce another directory for state information that does not belong in any of the existing categories (see also home-dir.proposal. Examples for this information are:

  • history files of shells, repls, anything that uses libreadline
  • logfiles
  • state of application windows on exit
  • recently opened files
  • last time application was run
  • emacs: bookmarks, ido last directories, backups, auto-save files, auto-save-list

The above example information is not essential data. However it should still persist on reboots of the system unlike cache data that a user might consider putting in a TMPFS. On the other hand the data is rather volatile and does not make sense to be checked into a VCS. The files are also not the data files that an application works on.

A default folder for a future STATE category might be: $HOME/.local/state

This would effectively introduce another environment variable since $XDG_DATA_HOME usually points to $HOME/.local/share and this hypothetical environment variable ($XDG_STATE_HOME?) would point to $HOME/.local/state

If you really want to adhere to the current standard I would place my log files in $XDG_CACHE_HOME since log files aren't required to run the program.

like image 151
harm Avatar answered Nov 09 '22 18:11

harm