renfeif
12 years agoNew Contributor
Error writing to the TC log file
I don't understand why the txt can't be written into my customization log file which is created during runtime.
//I can monitor the logfilepath variable is correct from debug mode and it should be appended with new input text..
var logFilePath;
var logFile;
logFilePath=CreateTCLLogFolder();
logFile=CreateTCLLogFile(logFilePath);
var emailLogName;
function main()
{
WriteLog(logFile,"Enter A2 Automation testing2");
}
function CreateTCLLogFolder()
{
var logFolder;
NowValue = aqDateTime.Now();
StringTodayValue=aqConvert.DateTimeToFormatStr(aqDateTime.Today(), '%y_%m_%d')
StringNowValue = aqConvert.DateTimeToStr(NowValue);
logFolder="C:\\TestCompleteLogs\\"+"TCL_LOG_"+StringTodayValue;
if (!aqFileSystem.Exists(logFolder))
aqFileSystem.CreateFolder(logFolder);
// Writes string to file
return logFolder;
}
function CreateTCLLogFile(LogFolder)
{
currentLogName=aqConvert.DateTimeToFormatStr(aqDateTime.Now(),"%H_%M")+".txt";
ForReading = 1;
ForWriting = 2;
ForAppending = 8;
TristateFalse = 0;
//s = LogTxt;
// Creates a new file object
fs = new ActiveXObject("Scripting.FileSystemObject")
if (! fs.FileExists(LogFolder+"\\"+currentLogName))
f = fs.CreateTextFile(LogFolder+"\\"+currentLogName);
return LogFolder+"\\"+currentLogName;
}
function WriteLog(logFilePath, logTxt)
{
fs = new ActiveXObject("Scripting.FileSystemObject")
timeStamp=aqConvert.DateTimeToFormatStr(aqDateTime.Now(),"%H_%M_%S")
if (!aqFile.Exists(logFilePath))
{
Log.Message("Log file doesn't exist, creating a new one");
aqFile.Create(logFilePath);
}
aqFile.WriteToTextFile(logFilePath, timeStamp+"==>"+ logTxt + "\r\n", aqFile.ctANSI, false); // this won't write!! Bizza!!
aqFile.WriteToTextFile("c:\\TestCompleteLogs\\TCL_LOG_13_12_09\\17_01.txt", timeStamp+"==>"+ logTxt + "\r\n", aqFile.ctANSI, false);//this works!!!
}
//I can monitor the logfilepath variable is correct from debug mode and it should be appended with new input text..
var logFilePath;
var logFile;
logFilePath=CreateTCLLogFolder();
logFile=CreateTCLLogFile(logFilePath);
var emailLogName;
function main()
{
WriteLog(logFile,"Enter A2 Automation testing2");
}
function CreateTCLLogFolder()
{
var logFolder;
NowValue = aqDateTime.Now();
StringTodayValue=aqConvert.DateTimeToFormatStr(aqDateTime.Today(), '%y_%m_%d')
StringNowValue = aqConvert.DateTimeToStr(NowValue);
logFolder="C:\\TestCompleteLogs\\"+"TCL_LOG_"+StringTodayValue;
if (!aqFileSystem.Exists(logFolder))
aqFileSystem.CreateFolder(logFolder);
// Writes string to file
return logFolder;
}
function CreateTCLLogFile(LogFolder)
{
currentLogName=aqConvert.DateTimeToFormatStr(aqDateTime.Now(),"%H_%M")+".txt";
ForReading = 1;
ForWriting = 2;
ForAppending = 8;
TristateFalse = 0;
//s = LogTxt;
// Creates a new file object
fs = new ActiveXObject("Scripting.FileSystemObject")
if (! fs.FileExists(LogFolder+"\\"+currentLogName))
f = fs.CreateTextFile(LogFolder+"\\"+currentLogName);
return LogFolder+"\\"+currentLogName;
}
function WriteLog(logFilePath, logTxt)
{
fs = new ActiveXObject("Scripting.FileSystemObject")
timeStamp=aqConvert.DateTimeToFormatStr(aqDateTime.Now(),"%H_%M_%S")
if (!aqFile.Exists(logFilePath))
{
Log.Message("Log file doesn't exist, creating a new one");
aqFile.Create(logFilePath);
}
aqFile.WriteToTextFile(logFilePath, timeStamp+"==>"+ logTxt + "\r\n", aqFile.ctANSI, false); // this won't write!! Bizza!!
aqFile.WriteToTextFile("c:\\TestCompleteLogs\\TCL_LOG_13_12_09\\17_01.txt", timeStamp+"==>"+ logTxt + "\r\n", aqFile.ctANSI, false);//this works!!!
}