Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

sl4j or log4j logging

Hi,
I tried configuring loggers in one of the pax.logging.cfg file, java.util.logging.properties files as below-
log4j.logger.com.mypackage.MyApp=DEBUG, out, stdout
in talend route java code-
org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(MyApp.class);
log.warn("sample log message");
the above statement does not log at any level ( WARN, DEBUG). Any idea? I get no logging errors as well 0683p000009MPcz.png
Also tried installing tlog4j and tlogcatcher components but, they found to be not available in Mediation view.

Labels (3)
8 Replies
Anonymous
Not applicable
Author

Did you test inside the Talend Runtime (OSGi) or outside? Inside the Talend Runtime it should just work. You should not even need to adjust the logging config as you are using .warn which should always be logged.
Anonymous
Not applicable
Author

I tested inside osgi container. I can see that loggers are working if implemented by -
org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(MyApp.class);
if(log.isWarnEnabled())
log.warn("sample log message");
but, I want it with org.slf4j.Logger as I am using some talend components that implement the logger this way. Are there any jars I am missing?
I already put sl4j-api-1.6.1, sl4j-log4j-1.6.1, common-logging.jar, log4j-1.2.16.jar in cconfig.
I also tried without configuring the properties and without jars. This way, sl4j is defaulting to NOP implementation.
Anonymous
Not applicable
Author

The problem may be exactly that you put the slf4j api in the config. As far as I know that means it is embedded into the jar. Probably that makes the slf4j invisble for pax logging. You can check the resulting jar of your route. It should not embed slf4j api and instead have an Import-Package for it.
Anonymous
Not applicable
Author

How do I make slf4j api as Import-Package ? I am using Talend. The reference is not present in Import-Package.
Anonymous
Not applicable
Author

I also saw that. I checked with the the dev team for the tooling. Currently it does not seem to be possible to use slf4j.
They are working on a solution. I hope we can at least add the import package statements to the manifest for the next bugfix release. For the longer term it is planned to allow users to specify their own imports.
Anonymous
Not applicable
Author

You might try to use the Advanced tab on the cMessageEndpoint rather than the cConfig. The behavior for exporting dependencies is slightly different than with cConfig.
Anonymous
Not applicable
Author

hmm, I don't seem to have any problem using slf4j within a cbean in 5.1.1. I assume the same would be true using routes developed with beans that were developed in Eclipse and imported into a Talend project I've attached links to a sample route (very trivial) that uses sl4j with log4j. It runs it both Studio and ESB runtime without problems. Perhaps I am misunderstanding the problem?
Here is the exported route http://eost.net/eost/slf4jTest/slf4jTest.zip
Anonymous
Not applicable
Author

Where is the log4J configuration in Talend 5.4.1 Studio? It used to be in Preferences -> Talend -> Run/Debug -> Log4j in 5.2.2 now it's gone. I don't understand why Talend removes features and then not document the change.