Is there a way to redirect the ACT log into a local text file?
I would like to tail a local log file, rather than opening the log through a product
Best Answer
-
import System import clr clr.AddReference("Ansys.ACT.Core") from Ansys.ACT.Core.Messages import * class MyLogger(ILogStream): def Write(self, value): stream = System.IO.StreamWriter(r"C:\testLog.out", True) stream.WriteLine(value) stream.Close() def Clear(self): print '' def ToString(self): return '' def GetLastContent(self, previousId, cleared): cleared = True return '' def get_Id(self): return 0 logger = MyLogger() Log.Stream = logger
0
Answers
-
@Landon Mitchell Kanner , thats great way to capture the logs.
Is there any possiblity to capture logs only from specific extension (this extension is binary addon from Mechanical), avoiding any logs from other extensions.
0 -
Is there any possiblity to capture logs only from specific extension (this extension is binary addon from Mechanical), avoiding any logs from other extensions.
By the time the message gets to the stream, there doesn't seem to be a way to know which extension sent it. So, I think you would have to intercept the messages further upstream, but I couldn't tell you how. If you had access to the extension's source code, you could probably toggle the stream back and forth between the default log and the file.
0