write headers before logging