请教一个log函数二次封装会崩溃的问题。

如题,想将log函数二次封装,以便将日志输出到文件中保存。我是这样写的
声明static bool _log(const char* format, …); //打印日志
定义bool MyUtils::_log(const char* format, …)
{
if (MyUtils::logFilePath.empty())
{
return false;
}

//获取时间
std::string nowtime = MyUtils::_getCurTime("%Y/%m/%d %H:%M:%S");
//形成带毫秒的log前缀
__String* prefix = __String::createWithFormat("%s%:%03d : ", nowtime.c_str(), clock()%CLOCKS_PER_SEC);

char log_char[512];
char buf[512];
memset(log_char, 0, 512);
memset(buf, 0, 512);
va_list args;
va_start(args, format);
_vsnprintf(buf, sizeof(buf) - 1, format, args);//可变参数形成字符串

// log(format, args); //调用原本的log 打印std::string会出错
va_end(args);

//形成最终的输出信息
snprintf(log_char, sizeof(log_char)-1, "%s%s", prefix->getCString(), buf);

ofstream outfile;
outfile.open(MyUtils::logFilePath.c_str(), ios::app);
outfile << log_char << endl;    //向文件输出
outfile.close();
return true;

}
在实际使用中,比如打印变量名字:
1、使用string:
std::string name = “zhang san”;
MyUtils::_log(“name=[%s]”,name.c_str());//会崩溃
2、使用__String
__String* frameName = _String::createWithFormat("up%d.png", i);
MyUtils::_log(“frameName = [%s]”, frameName->getCString());//正常写入文件

打印int、float之类的倒是正常。如果打印字符串,使用std::string就会崩溃,使用__String不会崩溃。如果将MyUtils::_log()原本的log()那行注释,使用std::string就不会崩,但调试log看不了了。。。
刚使用Cocos2d-X,求大佬。环境是最新版3.17,VS2015chm。