Skip to main content
Solved

How to get log generated in custom transformer ?

  • August 11, 2021
  • 2 replies
  • 80 views

I have a workbench which has a complex custom transformer added in which a python caller is present. I wanted to check what is happening in that python caller so I used some print statements. But I cannot find those print statements in logs that is being generated. How to get the log of a custom transformer in FME Desktop 2019.

Best answer by david_r

Print statements will appear in the on-screen log window, but will not necessarily be logged in the exact same order as the transformer messages, and may only appear on-screen and not in the log file. 

The best way to log messages is to use the FMELogFile object in the fmeobjects API. Example:

import fmeobjects
 
def my_function(feature):
    # Do something ...
    
    # Sends a message to the FME log file and console window.
    # Severity must be one of FME_INFORM, FME_WARN, FME_ERROR,
    # FME_FATAL, FME_STATISTIC, or FME_STATUSREPORT.
    message = 'This message will appear both on screen and in the log file'
    severity = fmeobjects.FME_INFORM
    fmeobjects.FMELogFile().logMessageString(message, severity)
 
    # Do something else here...

 

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

david_r
Celebrity
  • 8392 replies
  • Best Answer
  • August 11, 2021

Print statements will appear in the on-screen log window, but will not necessarily be logged in the exact same order as the transformer messages, and may only appear on-screen and not in the log file. 

The best way to log messages is to use the FMELogFile object in the fmeobjects API. Example:

import fmeobjects
 
def my_function(feature):
    # Do something ...
    
    # Sends a message to the FME log file and console window.
    # Severity must be one of FME_INFORM, FME_WARN, FME_ERROR,
    # FME_FATAL, FME_STATISTIC, or FME_STATUSREPORT.
    message = 'This message will appear both on screen and in the log file'
    severity = fmeobjects.FME_INFORM
    fmeobjects.FMELogFile().logMessageString(message, severity)
 
    # Do something else here...

 


  • Author
  • 2 replies
  • August 11, 2021

Print statements will appear in the on-screen log window, but will not necessarily be logged in the exact same order as the transformer messages, and may only appear on-screen and not in the log file. 

The best way to log messages is to use the FMELogFile object in the fmeobjects API. Example:

import fmeobjects
 
def my_function(feature):
    # Do something ...
    
    # Sends a message to the FME log file and console window.
    # Severity must be one of FME_INFORM, FME_WARN, FME_ERROR,
    # FME_FATAL, FME_STATISTIC, or FME_STATUSREPORT.
    message = 'This message will appear both on screen and in the log file'
    severity = fmeobjects.FME_INFORM
    fmeobjects.FMELogFile().logMessageString(message, severity)
 
    # Do something else here...

 

Got it.. Thanks