Putting NetBeans log directory on a temporary file system

Submitted by gunnar on

Whenever you do something, anything, in NetBeans, it will write to the uigestures file in the NetBeans log directory, .netbeans/8.2/var/log for NetBeans 8.2. I finally got tired of hearing my disk being written to every time I pressed a key so I decided to put the log directory on a temporary file system in memory. I imagine this will also be good for the future health of an SSD drive.

I'm using OpenSUSE Leap so there may be variations on other distros.

OpenSUSE will automatically create a directory for me in /run, which uses a tmpfs file system. My personal directory is called /run/user/1000 since 1000 is my uid. There is an environment variable, XDG_RUNTIME_DIR, that points to this directory.

The following script sets up the log directory and ensures that your NetBeans profile has a symbolic link to it:


# Create log directory for NetBeans in the temporary directory.
mkdir -p $XDG_RUNTIME_DIR/netbeans-log

# Determine latest NetBeans version and its var directory.
VERSION=$(ls -t -1 ${HOME}/.netbeans/|head -n 1)

# Ensure that the log directory is a link to the one in the temporary directory.
if [ ! -L ${VARDIR}/log ]
    rm -r $VARDIR/log
    ln -s $XDG_RUNTIME_DIR/netbeans-log $VARDIR/log

Save it somewhere suitable as for example netbeans-log-tmpfs and make it executable. Then make sure it is run when you log in. Since I use KDE, I use Startup/Shutdown in System Settings.