Hi Mark,
Fabien is right, you should have a default value.
You are using the rewrite rules that set $location inside an if statement.
Maybe what happens is that in some cases a log doesn't match which leads to an unset $location.
Don't you have directories with $location's value too?
So you have both:
("`BASEPATH`//$(lowercase ${HOST})/$app/$(lowercase ${HOST})_$app.log"
("`BASEPATH`/$location/$(lowercase ${HOST})/$app/$(lowercase ${HOST})_$app.log"
Or $location is always empty on the destination side?
Gabor