Logging best practices
Although the logging methods discussed above are very useful for debugging, they do generate a lot of data and slow down the execution. Here are some key considerations while using logging components.
- Logging components that are used only for debugging purposes (like tLogRow, tJavaRow, System.out.println) should be deactivated before being promoted to higher environments. Excessive logging will adversely affect the performance of the Jobs. Remember to disable or deactivate these components before moving your code to Production environments.
- If you are using Traces level for log4j to debug a Job, make sure to switch to the less verbose level Error in your production environment.
- Debug with a small set of data. In the rare case where you need a larger dataset, try to output log to a file instead of the console. With a couple of lines of Java code shown below in a tJava component, you can redirect the output to a file.
- For security reasons, in Talend Management Console, set
the Execution log level to Warning for
Jobs deployed to production. All logs flagged as Warning and Error will be displayed on the Task execution log page.