One Star

[resolved] How can I turn off the tMongoDBRow stdout log messages?

All of the mongo components print out a large amount of information to stdout. How may I turn this off ?
EDIT --
Sorry I just realized that its only the tMongoDBRow component, not the others. See the below post.
3 REPLIES
Moderator

Re: [resolved] How can I turn off the tMongoDBRow stdout log messages?

Hi,
What's kind of  information printed on console? Did you turn on tlogCatcher or tStatCatcher? Could you please upload screenshots into forum?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: [resolved] How can I turn off the tMongoDBRow stdout log messages?

Hi,
What's kind of  information printed on console? Did you turn on tlogCatcher or tStatCatcher? Could you please upload screenshots into forum?
Best regards
Sabrina

Hi Sabrina. I do not have a tLogCatcher or tStatCatcher turned on.
--- EDIT
I figured out that it was the tMongoDBRow component that prints everything to the console, and not the other mongodb components.
In this tMongoDBRow, I'm simply inserting a {'foo':'bar'} document into a collection, and get a lot of noise in the stdout:

If I take a look at the code and search for "System.out.println", I come to this portion which must be the culprit:
	 *  stop
*/
/**
* start
*/
currentComponent = "tMongoDBRow_1";
com.mongodb.Mongo mongo_tMongoDBRow_1 = null;
com.mongodb.DB db_tMongoDBRow_1 = null;
try {
mongo_tMongoDBRow_1 = (com.mongodb.Mongo) globalMap
.get("mongo_tMongoDBConnection_1");
db_tMongoDBRow_1 = (com.mongodb.DB) globalMap
.get("db_tMongoDBConnection_1");
com.mongodb.CommandResult result_tMongoDBRow_1 = null;
result_tMongoDBRow_1 = db_tMongoDBRow_1
.doEval("db.test.insert({'foo':'bar'})");
if (result_tMongoDBRow_1.ok()) {
System.out.println(result_tMongoDBRow_1);
} else {
System.err.println(result_tMongoDBRow_1);
}
} catch (Exception e_tMongoDBRow_1) {
System.err.println(e_tMongoDBRow_1.getMessage());
}
tos_count_tMongoDBRow_1++;
/**
* stop
*/
/**
* start
*/

Specifically, this piece:
if (result_tMongoDBRow_1.ok()) {
System.out.println(result_tMongoDBRow_1);
} else {
System.err.println(result_tMongoDBRow_1);
}

I don't think its necessary to print to standard out when everything is OK. Perhaps there should be an option in the tMongoDBRow component to print debugging messages, instead.
One Star

Re: [resolved] How can I turn off the tMongoDBRow stdout log messages?

Ok, here is a temporary workaround.
Create a job that you will use as a subjob from now on every time you wish to use a tMongoDBRow without having it print to stdout.
Create a context variable of type String called "mongo string".
Add a tMongoDBConnection-->tJava-->tMongoDBRow-->tJava like so:

In the first tJava before the tMongoDBRow, redirect stdout to nothing with the following:
System.setOut(new java.io.PrintStream(new java.io.ByteArrayOutputStream()));

In the tMongoDBRow, set the function to context.mongo_string.


In the last tJava, direct stdout to the default via:
System.setOut(new java.io.PrintStream(new java.io.FileOutputStream(java.io.FileDescriptor.out)));

Now when you run the job, the stdout logging messages will be supressed:


This works but I think that there should be a check box allowing the user to chose whether these messages should be printed or not.