<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Log4j using ThreadContext and also Custom log levels in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Log4j-using-ThreadContext-and-also-Custom-log-levels/m-p/2375721#M138077</link>
    <description>&lt;P&gt;Hi !&lt;/P&gt;&lt;P&gt;In open studio 7.3 (free) I've enabled log4j and configured properties with some custom log levels.&lt;/P&gt;&lt;P&gt;Also use MDC/ThreadContext to add custom 'columns' in my logging to make the processing and monitoring (in Elastic/Kibana) a little easier.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When Im using &lt;B&gt;tRunJob &lt;/B&gt;with &lt;B&gt;&lt;I&gt;dynamic jobs &lt;/I&gt;&lt;/B&gt;defined&lt;I&gt;, &lt;/I&gt;it triggers the corresponding job based on its given input &lt;B&gt;NAME&lt;/B&gt;. In this scenario the ThreadContext works fine.&lt;/P&gt;&lt;P&gt;In a scenario where multiple jobs (when a list of multiple jobnames is given as input) runs the ThreadContext is not working, only for the first job... &lt;/P&gt;&lt;P&gt;I assumed ThreadContext implies its in the same thread, log suggest [main] so that should be the case.&lt;/P&gt;&lt;P&gt;Within properties in pattern you access it by&lt;B&gt;&lt;I&gt; %X{NAME} &lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a different/better way or approach to implement ThreadContext? Help is suggestions appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;P&gt;Jesper&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For those who like to know how/what:&lt;/P&gt;&lt;P&gt;Here's what I've implemented so far and works.&lt;/P&gt;&lt;P&gt;&lt;B&gt;Properties:&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;CustomLevels&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;CustomLevel name="CONFIG" intLevel="310" /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;CustomLevel name="EVENT" intLevel="320" /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;CustomLevel name="SQL" intLevel="330" /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/CustomLevels&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I add java-component and add the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Java-code in java component:&lt;/B&gt;&lt;/P&gt;&lt;P&gt;// Code&lt;/P&gt;&lt;P&gt;org.apache.logging.log4j.ThreadContext.put("NAME", "Example");&amp;nbsp;&lt;/P&gt;&lt;P&gt;log.log( org.apache.logging.log4j.Level.getLevel("EVENT") ,"SQL-scripts");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Log result(s):&lt;/B&gt;&lt;/P&gt;&lt;P&gt;[statistics] connected&lt;/P&gt;&lt;P&gt;&lt;B&gt;Example &lt;/B&gt;14:25:58.511	[main]	EVENT	SQL-scripts&lt;/P&gt;&lt;P&gt;&lt;B&gt;Example 	&lt;/B&gt;14:25:58.699	[main]	CONFIG	Parameters jobName:PerfectView, taskName:ExtractSources, initialLoad:false, startDT:2010-01-01T00:00:00.000+0100, endDT:2020-08-20T23:59:59.000+0200, jsonConfigFilePath:/data/PROD_jobconfig_tos.json&lt;/P&gt;&lt;P&gt;[statistics] disconnected&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 01:37:12 GMT</pubDate>
    <dc:creator>Jesperrekuh</dc:creator>
    <dc:date>2024-11-16T01:37:12Z</dc:date>
    <item>
      <title>Log4j using ThreadContext and also Custom log levels</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Log4j-using-ThreadContext-and-also-Custom-log-levels/m-p/2375721#M138077</link>
      <description>&lt;P&gt;Hi !&lt;/P&gt;&lt;P&gt;In open studio 7.3 (free) I've enabled log4j and configured properties with some custom log levels.&lt;/P&gt;&lt;P&gt;Also use MDC/ThreadContext to add custom 'columns' in my logging to make the processing and monitoring (in Elastic/Kibana) a little easier.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When Im using &lt;B&gt;tRunJob &lt;/B&gt;with &lt;B&gt;&lt;I&gt;dynamic jobs &lt;/I&gt;&lt;/B&gt;defined&lt;I&gt;, &lt;/I&gt;it triggers the corresponding job based on its given input &lt;B&gt;NAME&lt;/B&gt;. In this scenario the ThreadContext works fine.&lt;/P&gt;&lt;P&gt;In a scenario where multiple jobs (when a list of multiple jobnames is given as input) runs the ThreadContext is not working, only for the first job... &lt;/P&gt;&lt;P&gt;I assumed ThreadContext implies its in the same thread, log suggest [main] so that should be the case.&lt;/P&gt;&lt;P&gt;Within properties in pattern you access it by&lt;B&gt;&lt;I&gt; %X{NAME} &lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a different/better way or approach to implement ThreadContext? Help is suggestions appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;P&gt;Jesper&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For those who like to know how/what:&lt;/P&gt;&lt;P&gt;Here's what I've implemented so far and works.&lt;/P&gt;&lt;P&gt;&lt;B&gt;Properties:&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;CustomLevels&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;CustomLevel name="CONFIG" intLevel="310" /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;CustomLevel name="EVENT" intLevel="320" /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;CustomLevel name="SQL" intLevel="330" /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/CustomLevels&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I add java-component and add the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Java-code in java component:&lt;/B&gt;&lt;/P&gt;&lt;P&gt;// Code&lt;/P&gt;&lt;P&gt;org.apache.logging.log4j.ThreadContext.put("NAME", "Example");&amp;nbsp;&lt;/P&gt;&lt;P&gt;log.log( org.apache.logging.log4j.Level.getLevel("EVENT") ,"SQL-scripts");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Log result(s):&lt;/B&gt;&lt;/P&gt;&lt;P&gt;[statistics] connected&lt;/P&gt;&lt;P&gt;&lt;B&gt;Example &lt;/B&gt;14:25:58.511	[main]	EVENT	SQL-scripts&lt;/P&gt;&lt;P&gt;&lt;B&gt;Example 	&lt;/B&gt;14:25:58.699	[main]	CONFIG	Parameters jobName:PerfectView, taskName:ExtractSources, initialLoad:false, startDT:2010-01-01T00:00:00.000+0100, endDT:2020-08-20T23:59:59.000+0200, jsonConfigFilePath:/data/PROD_jobconfig_tos.json&lt;/P&gt;&lt;P&gt;[statistics] disconnected&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 01:37:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Log4j-using-ThreadContext-and-also-Custom-log-levels/m-p/2375721#M138077</guid>
      <dc:creator>Jesperrekuh</dc:creator>
      <dc:date>2024-11-16T01:37:12Z</dc:date>
    </item>
  </channel>
</rss>

