Skip to main content
Hi all,

 

I've a workbench with one reader and one writer. if the traitment is issue i would retrieve the raisons or logs into file (my writer or another file).

 

Any idea?

 

Thanks an advance.

 

FarFar 
Hi FarFar,

 

 

If you want to write only error messages into a file automatically, define a function to collect error messages in the Sartup Pytnon Script, and write the messages in the Shutdown Script. For example:

 

-----

 

# Startup Python Script

 

import fmeobjects

 

 

# Error message collector.

 

errorMessages = s]

 

 

# Callback function

 

def collectErrorMessages(severity, message):

 

    if severity == fmeobjects.FME_ERROR or severity == fmeobjects.FME_FATAL:

 

        errorMessages.append(message)

 

 

# Set the function to the FME LogFile object

 

logFile = fmeobjects.FMELogFile()

 

logFile.setCallBack(collectErrorMessages)

 

logFile = None

 

-----

 

# Shutdown Python Script

 

if 0 < len(errorMessages):

 

    f = open('C:\\\\tmp\\\\error_log.txt', 'w')

 

    for msg in errorMessages:

 

        f.write('%s\\n' % msg)

 

    f.close()

 

-----

 

 

Takashi

Reply