Custom components tlog4j and tinitlog4j not functioning when deploying to talend runtime container (Talend version 7) (TOS ESB)

Five Stars

Custom components tlog4j and tinitlog4j not functioning when deploying to talend runtime container (Talend version 7) (TOS ESB)



I am trying to deploy a job with tlog4j (and tinitlog4j) components - these are custom components from the exchange. When I try locally , the job will function (I see output in the console and in the file configured as logger output in the log4j xml config). If I export as "standalone job", the job also functions correctly. However, when I try to export this job as OSGI and deploy it to a container, the logging appears to be completely disabled - there is no console output and no file output, and no error or anything else in the tesb.log or in the karaf log.


Has anyone had this problem and knows how to fix it? Any help would be appreciated. Thanks.
I attach a jpg of my simple test job .


Five Stars

Re: Custom components tlog4j and tinitlog4j not functioning when deploying to talend runtime container (Talend version 7) (TOS ESB)

After some experimenting I have found out that there is actually an exception thrown, which was not being logged anywhere. It looks like one of the dependencies can't be found:


Exception in component tRESTRequest_1_In (testservicelog)
java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/apache/log4j/BasicConfigurator
        at local_project.testservicelog_0_1.testservicelog.tRESTRequest_1_LoopProcess(
        at local_project.testservicelog_0_1.testservicelog$RestServiceProviderImpl4TalendJob.processRequest(
        at local_project.testservicelog_0_1.testservicelog$
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor$
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(
        at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(
        at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(
        at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(
        at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
        at org.eclipse.jetty.server.Server.handle(
        at org.eclipse.jetty.server.HttpChannel.handle(
        at org.eclipse.jetty.server.HttpConnection.onFillable(
        at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(
        at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(
        at org.eclipse.jetty.util.thread.QueuedThreadPool$
        at Source)
Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/BasicConfigurator
        at org.courtine.talend.log4j.TalendLog4JConfigurator.configureLog4J(
        at local_project.testservicelog_0_1.testservicelog.tInitLog4J_1Process(
        at local_project.testservicelog_0_1.testservicelog.tFixedFlowInput_1Process(
        at local_project.testservicelog_0_1.testservicelog.tRESTRequest_1_LoopProcess(
        ... 34 more


I tried to manually import the needed dependencies in the job but this does not appear to solve the problem. Anyone have any ideas?

Five Stars

Re: Custom components tlog4j and tinitlog4j not functioning when deploying to talend runtime container (Talend version 7) (TOS ESB)

I have managed to work around this issue in the meantime.

It looks like it is not easily possible to use the tlog4j custom components with the Runtime (at least not in the latest versions  - 6.x or 7.x). The components rely on using a custom written log4j config and loading this with some methods/classes in the "standalone" log4j library - the karaf container uses pax logging and different implementations to "catch" logging from different frameworks. This means that some parts of the API have noop implementations - in this situation, parts used by these old custom components, namely by the tinitlog4j component.

What instead must be done is to modify the config files for the container logging directly ( <runtimefolder>/container/etc/org.ops4j.pax.logging.cfg ) and add any custom loggers and appenders there. Then in the job simply use a tJava type of component where you call log4j.getLogger("yourLoggerName"). One minor inconvenience was that not all messages are displayed to the console in the studio (I think only > Warn levels are displayed) so this made debugging the logging a bit harder but I got around this by writing a small routine which automatically prints every log command also to console.

One of the needs I had was to be able to easily have a separate log file per job, which can be achieved by using a "Routing" type appender - this was called "sifting" appender in the older versions of Karaf I believe - and will actually create a separate log file per bundle (in this case,per job).



Talend named a Leader.

Get your copy


Kickstart your first data integration and ETL projects.

Download now

Talend API Designer – Technical Overview

Take a look at this technical overview video of Talend API Designer

Watch Now

Getting Started with APIs

Find out how to get started with APIs