VanDyke Software Forums

VanDyke Software Forums (
-   Scripting (
-   -   Default log file name changed after script is ran. (

pichi 08-27-2021 10:34 AM

Default log file name changed after script is ran.
Hello VanDyke team,

I have in the session option the default log file name set as follows "V:\logs\%S_%Y_%M%D.log" but every time I run a script that logs to a specific log file name and closes it, when I open the session again and want to log the work done the default session log file name is changed to the name last used in the script e.g "V:\script_log_date.log", Is there a way to keep the default log file name as specified in the session option after the script is complete "V:\logs\%S_%Y_%M%D.log"?

thanks for your support.

gregg 08-30-2021 11:26 AM

I think one way to accomplish this is to capture the current name, set new name, start log, reset name.


# $language = "Python"
# $interface = "1.0"

s = crt.Session
config = s.Config
orig_name = config.GetOption("Log Filename")
s.LogFileName = "my-new-file.log"
s.Log(True, True)
s.LogFileName = orig_name

# rest of script / terminal work

Changing the LogFileName after starting the log does not seem to affect the current log stream.

Note: had to use config.GetOption() to retain the raw "%S_%Y_%M%D" - because s.LogFileName returns the substituted name.

All times are GMT -6. The time now is 10:12 PM.