iLogic log files

iLogic log files

Curtis_Waguespack
Consultant Consultant
1,960 Views
3 Replies
Message 1 of 4

iLogic log files

Curtis_Waguespack
Consultant
Consultant

Is there a way to get only part of the the iLogic Log file to write out? 

 

I have something like this, but it brings in all of the information for the entire Inventor session. I'd like to run a rule that does stuff, and writes information to the Logger and then saves that out to a file, but I only want to see the Logger information for that rule not the entire Inventor session.

 

Is there a way to clear the log first, or capture only what happens from one "event" to another, etc

 

'Start rule

' < do some stuff here > 
Logger.Info("some info about the stuff that just happened...")

' < do more some stuff here > 
Logger.Info("some info about the stuff that just happened...")

' < do even more some stuff here > 
Logger.Info("some info about the stuff that just happened...")

'write out the log file 
iLogicVb.Automation.LogControl.SaveLogAs("C:\TEMP\iLogic Log Example.txt")

'end rule

 

I looked at accessing the logger file using the fullfilename, but I wasn't able to do much with that file while Inventor is using it, etc.

iLogicVb.Automation.LogControl.FullFileName

 

Thanks in advance!

EESignature

0 Likes
Accepted solutions (1)
1,961 Views
3 Replies
Replies (3)
Message 2 of 4

Curtis_Waguespack
Consultant
Consultant

@MjDeck 

 

would you have any information on these questions?

EESignature

0 Likes
Message 3 of 4

MjDeck
Autodesk
Autodesk
Accepted solution

Hi @Curtis_Waguespack ,

There's no straightforward way to do it. We could add that in a future release.

But here's a hack. Write a marker, and then delete all the text before the last marker.

Dim startMarker = "------ Custom iLogic Log marker --------"
Logger.Info(startMarker)

' < do some stuff here > 
Logger.Info("some info about the stuff that happened starting at " & DateTime.Now)

' < do more some stuff here > 
Logger.Info("some more info about the stuff that just happened...")

'write out the log file 
Dim logFileName = "C:\TEMP\iLogic Log Example.txt"
iLogicVb.Automation.LogControl.SaveLogAs(logFileName)

Dim logText = System.IO.File.ReadAllText(logFileName)
Dim markerIndex = logText.LastIndexOf(startMarker)
' Replace the file contents with the portion from the last marker
System.IO.File.WriteAllText(logFileName, logText.Substring(markerIndex))

Mike Deck
Software Developer
Autodesk, Inc.

Message 4 of 4

Curtis_Waguespack
Consultant
Consultant

Thanks for the reply and the example code... that's helpful and will allow me to write out information to the logger for debugging, etc. and still drop it off for users to look at as an external log/report, without having to double the effort in the code.

EESignature

0 Likes