Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[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.
Labels (2)
3 Replies
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

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:
0683p000009MEqH.png
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.
Anonymous
Not applicable
Author

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:
0683p000009MEqM.png
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.

0683p000009MEhf.png
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:

0683p000009MEqR.png
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.