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

Landon Mitchell Kanner
Landon Mitchell Kanner Member, Employee Posts: 291
100 Comments 25 Answers 25 Likes Photogenic
✭✭✭✭

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 Posts: 291
    100 Comments 25 Answers 25 Likes Photogenic
    ✭✭✭✭
    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
    First Anniversary 10 Comments Name Dropper 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 Posts: 291
    100 Comments 25 Answers 25 Likes Photogenic
    ✭✭✭✭
    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.