Note
This parameter is used to set the folder on a computer in where a log file generated by the PCAN-Basic will be stored, and to start a debug session.
If a debug session is running (a log file is being written), LogLocation instructs the API to close the current log file, create another one in the new location, and continue debugging using that new file. To keep track of the log files used, the path to the new log file is written in the old one, and the path to the old log file is written in the new one.
It is available since PCAN-Basic version 1.0.0.
None: Logging parameters are used globally, i.e., they are not tied to a specific PCAN Channel, but to a specific process.
This parameter is read/write. It can be configured and retrieved.
This value is a string containing a fully qualified and valid path to an existing directory on the executing computer. To use the default path (calling process path) an empty string must be set.
Kind of Path | Value |
|---|---|
Custom path | A valid directory string (see Files and Paths). |
Default path (calling process folder) | An empty string. |
The default value is the path to the calling process folder.
Get: Not relevant since this parameter is not channel dependent.
Set: Not relevant since this parameter is not channel dependent.
The following code shows how to set the location of a log file and to start a debug session:
try
{
System.IO.DirectoryInfo info = System.IO.Directory.CreateDirectory(System.IO.Path.GetTempPath() + "Logging_" + DateTime.Now.Date.ToString("yyyy.mm.dd"));
if (Api.SetValue(PcanChannel.None, PcanParameter.LogLocation, info.FullName) == PcanStatus.OK)
{
Console.WriteLine($"Logging is active. The log file is located at:\n{info.FullName}");
}
else
{
Console.WriteLine("Error configuring the location of the log file.");
}
}
catch (Exception ex)
{
Console.WriteLine($"Error creating a folder: {ex.Message}.");
}Try
Dim info As System.IO.DirectoryInfo = System.IO.Directory.CreateDirectory(System.IO.Path.GetTempPath() & "Logging_" & Date.Now.[Date].ToString("yyyy.mm.dd"))
If Api.SetValue(PcanChannel.None, PcanParameter.LogLocation, info.FullName) = PcanStatus.OK Then
Console.WriteLine($"Logging is active. The log file is located at: {info.FullName}")
Else
Console.WriteLine("Error configuring the location of the log file.")
End If
Catch ex As Exception
Console.WriteLine($"Error creating a folder: {ex.Message}.")
End Trytry
{
System::IO::DirectoryInfo^ info = System::IO::Directory::CreateDirectory(System::IO::Path::GetTempPath() + "Logging_" + DateTime::Now.Date.ToString("yyyy.mm.dd"));
if (Api::SetValue(PcanChannel::None, PcanParameter::LogLocation, info->FullName) == PcanStatus::OK)
{
Console::WriteLine("Logging is active. The log file is located at:\n{0}", info->FullName);
}
else
{
Console::WriteLine("Error configuring the location of the log file.");
}
}
catch (Exception^ ex)
{
Console::WriteLine("Error creating a folder: {0}.", ex->Message);
}