日志的参数问题
我想通过配制参数的方式定义ACE的输出方式,结果在程序退出的时候,出现异常。经调试如果参数是通过配制文件读取,运行结果结果正确,但退出时异常。通过程序写死时,运行正常,退出也正确。整个工程代码见附件。std::string Value = CIniFile::GetValue("nParaNum","LogControl",FileName);
num = ACE_OS::atoi(Value.c_str());
if (num < 1) //如果小于1,则一切OK
{
l_argv = (ACE_TCHAR *)ACE_TEXT ("Logging_Strategy_Class");
l_argv = (ACE_TCHAR *) ACE_TEXT("-w");
l_argv = (ACE_TCHAR *) ACE_TEXT ("-fSTDERR");
l_argv = (ACE_TCHAR *) ACE_TEXT ("-slog/test.log");
l_argv = 0;
if (parse_args (4, l_argv) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"Invalid command-line parameters.\n"),
false);
argc = 4;
}else //如果num > 0 ,则运行正确,但退出异常
{
if (num > 9)
{
num = 9;
}
l_argv = (ACE_TCHAR *)ACE_TEXT ("Logging_Strategy_Class");
for (int i = 0; i < num ; i++)
{
ACE_OS::sprintf(szPara,"Para%d",i);
Value = CIniFile::GetValue(szPara,"LogControl",FileName);
l_argv = new ACE_TCHAR;
ACE_OS::strcpy(l_argv,ACE_TEXT(Value.c_str()));
}
l_argv = 0;
argc = num+1;
if (parse_args (num, l_argv) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"Invalid command-line parameters.\n"),
false);
} 原来是配制参数不太对
页:
[1]