LogLocation

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.

  Note

Setting this parameter starts recording debug information automatically if the logging functionality was inactive. It is not needed to call SetValue with the LogStatus parameter afterwards to activate 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.

  Note

The name of a log file cannot be changed. It is always PCANBasic.log.

Availability

It is available since PCAN-Basic version 1.0.0.

Supported By

  • None: Logging parameters are used globally, i.e., they are not tied to a specific PCAN Channel, but to a specific process.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

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.

Default Value

The default value is the path to the calling process folder.

Initialization Status

Get: Not relevant since this parameter is not channel dependent.

Set: Not relevant since this parameter is not channel dependent.

Example

The following code shows how to set the location of a log file and to start a debug session:

C#
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}.");
}

See Also