Logging operator executions
nico_timotius
New Altair Community Member
Hi RapidMiner Community,
I've managed to deploy my process into a web service using RapidMiner Server. I think it will be beneficial if the web service can have a log just like a log4j. I am thinking to create a log for the web service so it will show something like this
I think it will be helpful to solve issues found if the web service used in a production environment. I am aware there are log related operators such as Log, Log to Data but it can only manage to capture one information from an operator.
Do you have any suggestion of ways to achieve that kind of need?
Thank you
TN
I've managed to deploy my process into a web service using RapidMiner Server. I think it will be beneficial if the web service can have a log just like a log4j. I am thinking to create a log for the web service so it will show something like this
INFO [2019-03-29 14:55:56] Start A Prediction Process
INFO [2019-03-29 14:55:56] Input Data : {AAAA,BBBB}
INFO [2019-03-29 14:55:56] Preprocess the data
INFO [2019-03-29 14:55:59] Load Model
ERROR [2019-03-29 14:55:59] SomethingWrongWithTheModelException
INFO [2019-03-29 14:55:59] End A Prediction Process
Do you have any suggestion of ways to achieve that kind of need?
Thank you
TN
Tagged:
0
Best Answer
-
Hi,The process below shows an example about how to use both logging mechanisms. You can see the result if you activate the "Log" panel in the menu "View" - "Show Panel...". I also used some macros in those messages to demonstrate how to create those dynamically.The only thing I would like to add is that I personally would prefer
operator.getLogger().log(Level level, String text);
instead of the getLog() method Martin has mentioned. But both should work.Hope this helps,
Ingo<?xml version="1.0" encoding="UTF-8"?><process version="9.2.001"><br> <context><br> <input/><br> <output/><br> <macros/><br> </context><br> <operator activated="true" class="process" compatibility="9.2.001" expanded="true" name="Process"><br> <parameter key="logverbosity" value="init"/><br> <parameter key="random_seed" value="2001"/><br> <parameter key="send_mail" value="never"/><br> <parameter key="notification_email" value=""/><br> <parameter key="process_duration_for_mail" value="30"/><br> <parameter key="encoding" value="UTF-8"/><br> <process expanded="true"><br> <operator activated="true" class="retrieve" compatibility="9.2.001" expanded="true" height="68" name="Retrieve Golf" width="90" x="45" y="34"><br> <parameter key="repository_entry" value="//Samples/data/Golf"/><br> </operator><br> <operator activated="true" class="extract_macro" compatibility="9.2.001" expanded="true" height="68" name="Extract Macro" width="90" x="179" y="34"><br> <parameter key="macro" value="number_of_rows"/><br> <parameter key="macro_type" value="number_of_examples"/><br> <parameter key="statistics" value="average"/><br> <parameter key="attribute_name" value=""/><br> <list key="additional_macros"/><br> </operator><br> <operator activated="true" class="print_to_console" compatibility="9.2.001" expanded="true" height="82" name="Print to Console" width="90" x="313" y="34"><br> <parameter key="log_value" value="Number of rows is %{number_of_rows}"/><br> </operator><br> <operator activated="true" class="execute_script" compatibility="9.2.001" expanded="true" height="82" name="Execute Script" width="90" x="447" y="34"><br> <parameter key="script" value="import java.util.logging.Level; ExampleSet inputData = input[0]; operator.getLogger().log(Level.INFO, "Number of rows: " + %{number_of_rows}); return inputData;"/><br> <parameter key="standard_imports" value="true"/><br> </operator><br> <connect from_op="Retrieve Golf" from_port="output" to_op="Extract Macro" to_port="example set"/><br> <connect from_op="Extract Macro" from_port="example set" to_op="Print to Console" to_port="through 1"/><br> <connect from_op="Print to Console" from_port="through 1" to_op="Execute Script" to_port="input 1"/><br> <connect from_op="Execute Script" from_port="output 1" to_port="result 1"/><br> <portSpacing port="source_input 1" spacing="0"/><br> <portSpacing port="sink_result 1" spacing="0"/><br> <portSpacing port="sink_result 2" spacing="0"/><br> </process><br> </operator><br></process>
2
Answers
-
Hi,i think Print to Console is the operator doing what you want. We use also log4j if i see this correctly for our own logging. You can also use the logging system with execute script. Just do
<div><br></div><div>operator.getLog().log(String message, Integer Level) </div>
for this.
Best,
Martin1 -
Hi Martin,
Thanks for the answer. I don't think i managed to use the mentioned operator properly. Is there any tutorial? I can't find the tutorial on the operator.
Best,
TN0 -
Hi,The process below shows an example about how to use both logging mechanisms. You can see the result if you activate the "Log" panel in the menu "View" - "Show Panel...". I also used some macros in those messages to demonstrate how to create those dynamically.The only thing I would like to add is that I personally would prefer
operator.getLogger().log(Level level, String text);
instead of the getLog() method Martin has mentioned. But both should work.Hope this helps,
Ingo<?xml version="1.0" encoding="UTF-8"?><process version="9.2.001"><br> <context><br> <input/><br> <output/><br> <macros/><br> </context><br> <operator activated="true" class="process" compatibility="9.2.001" expanded="true" name="Process"><br> <parameter key="logverbosity" value="init"/><br> <parameter key="random_seed" value="2001"/><br> <parameter key="send_mail" value="never"/><br> <parameter key="notification_email" value=""/><br> <parameter key="process_duration_for_mail" value="30"/><br> <parameter key="encoding" value="UTF-8"/><br> <process expanded="true"><br> <operator activated="true" class="retrieve" compatibility="9.2.001" expanded="true" height="68" name="Retrieve Golf" width="90" x="45" y="34"><br> <parameter key="repository_entry" value="//Samples/data/Golf"/><br> </operator><br> <operator activated="true" class="extract_macro" compatibility="9.2.001" expanded="true" height="68" name="Extract Macro" width="90" x="179" y="34"><br> <parameter key="macro" value="number_of_rows"/><br> <parameter key="macro_type" value="number_of_examples"/><br> <parameter key="statistics" value="average"/><br> <parameter key="attribute_name" value=""/><br> <list key="additional_macros"/><br> </operator><br> <operator activated="true" class="print_to_console" compatibility="9.2.001" expanded="true" height="82" name="Print to Console" width="90" x="313" y="34"><br> <parameter key="log_value" value="Number of rows is %{number_of_rows}"/><br> </operator><br> <operator activated="true" class="execute_script" compatibility="9.2.001" expanded="true" height="82" name="Execute Script" width="90" x="447" y="34"><br> <parameter key="script" value="import java.util.logging.Level; ExampleSet inputData = input[0]; operator.getLogger().log(Level.INFO, "Number of rows: " + %{number_of_rows}); return inputData;"/><br> <parameter key="standard_imports" value="true"/><br> </operator><br> <connect from_op="Retrieve Golf" from_port="output" to_op="Extract Macro" to_port="example set"/><br> <connect from_op="Extract Macro" from_port="example set" to_op="Print to Console" to_port="through 1"/><br> <connect from_op="Print to Console" from_port="through 1" to_op="Execute Script" to_port="input 1"/><br> <connect from_op="Execute Script" from_port="output 1" to_port="result 1"/><br> <portSpacing port="source_input 1" spacing="0"/><br> <portSpacing port="sink_result 1" spacing="0"/><br> <portSpacing port="sink_result 2" spacing="0"/><br> </process><br> </operator><br></process>
2 -
Hi Mr Ingo and Mr Martin,
Thanks for the help. What a great community
Best Regards,
TN2