Welcome to the VanDyke Software Forums

Join the discussion today!

Go Back   VanDyke Software Forums > Scripting


Thread Tools Rate Thread Display Modes
Old 08-27-2021, 09:34 AM
pichi pichi is offline
Junior Member
Join Date: Oct 2010
Posts: 8
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.
Reply With Quote
Old 08-30-2021, 10:26 AM
gregg gregg is offline
Registered User
Join Date: Oct 2010
Posts: 75
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.

Last edited by gregg; 08-30-2021 at 10:39 AM. Reason: address % vars in log filename
Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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