add check permission and create log directory

Signed-off-by: Fudong Bai <fudongbai@gmail.com>