Is there a way to redirect the ACT log into a local text file?

Landon Mitchell Kanner
Landon Mitchell Kanner Member, Employee, GitHub-issue-creator Posts: 319
50 Answers 100 Comments Second Anniversary 25 Likes
✭✭✭✭

I would like to tail a local log file, rather than opening the log through a product

Best Answer

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee, GitHub-issue-creator Posts: 319
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    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
    
    

Answers

  • kanchan_cadfem
    kanchan_cadfem Member Posts: 20
    10 Comments First Anniversary 5 Likes First Answer
    **

    @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.

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee, GitHub-issue-creator Posts: 319
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    edited September 18

    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.