changed setlog() to writelog()