Fix bug if log to console is true