Lock when changing a logger or writing to the logger, to avoid race conditions when the statistics thread is logging as a logger is being destroyed.