Moved logging initialization code up

Now various subsystems like cache can report their errors
with correct log levels while initializing.