Enable/Disable tLogRow in Talend by Context Variable

You may need to add some tLogRow components in your Talend job to monitor during test the ETL progress, but then you need to turn them off when you run the job in production.

Probably you have already at least two contexts: the one you use in the test environment and the one to be used in production.

Well, there is a simple technique to disable ALL the tLogRow components (or enable all them) with a context variable.

That is done setting a global variable using the tSetGlobalVar. tLogRow uses a PrintStream saved in the global variables map, and, if not already set, it instantiate a PrintStream only once.

So, if before the “real” job starts we add a tSetGlobalVar component which sets the tLogRow stream to a null stream, we’re done, no more logs are printed.

How to do it

First we need a context variable to control the logging. Let call it “log” and be a boolean value.

With in the tSetGlobalVar component we add the key "tLogRow_CONSOLE" which is the global map key under which tLogRow search for a stream.

We set the value for that key in this way:


(you should change “/dev/null” to “NUL” on Windows)

That creates a “null” stream and the logs printed by tLogRow are thrown away.

Of course you can even import the Apache Commons IO and use one of their predefined null streams, it’s up to you.

Leave a Reply