This your requirement you can achieve with log4j as well. Why are you guys using tLog4jInit and other components, the log4j support is already built in Talend itself. Look into File -> Project Settings -> Log4j. There you have the template (log4j.xml) configuration available. When you run from command line, you need to pass argument to the job to activate log4j by:
-DLOG4J_ENABLED=true
If you would like to achieve
DYNAMIC FILE NAME PER JOB, then you can instead of hardcoded name use following snippet of config data:
<appender name="STD-OUT FILE" class="org.apache.log4j.FileAppender">
<param name="File" value="C:/p4/Logging/${TalendJob.log}.STDOUT"/>
<param name="Threshold" value="TRACE"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d - %c -%-4r %-5p %x - %m%n" />
</layout>
</appender>
That's it.
regarding log4j2 I am affraid there will be required to change the class load from:
org.apache.log4j.Logger
to:
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class MyTalendClass {
private static final Logger logger = LogManager.getLogger("MyTalendClass");
I created 2 new feature tickets available at:
Support for Apache Log4j2
This is about how I see the future logging in Talend, you can use log4j JDBC subsystem to log for database filtered messages (ERROR and WARNING and even more filtering on content.
Another story is auditing execution Talend job out of the box. The idea is that the Job template itself with log 3 basic events which are happening inside:
ENTRY - the job is going to be executed
EXIT - the job finished without issue
ERROR - the job finished with error
You can then easily see ENTRY-EXIT pairs and you know it is fine, or you log ENTRY-ERROR and something is wrong, any other combination is considered as bug.
This can be extended with also component based flow events:
tComponentEntry
tComponentError
tComponentExit
enriched by some metadata.
For such purposes there can be created specific log level for example called AUDIT which can show the sequence execution and store this sequence into database for automated checking of the health status and monitoring purposes. In case of log4j via JDBC subsystem again.
This is can be achieved by 2 ways:
There will be added somewhere to tLogCatcher and other logging components some checkboxes to capture new events. Or it will be implemented inside the Job template itself and can be configured globally via File-> Project Settings.....
I created another ticket for this, let's see if this idea will find others to support
🙂
Audit logging of job execution
Ladislav