#1 2012-06-25 11:51:37

vnodkmar
Member
Registered: 2012-02-10
Posts: 31

sl4j or log4j logging

Tags: [log, log4j, sl4j]

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 sad

Also tried installing tlog4j and tlogcatcher components but, they found to be not available in Mediation view.

Offline

#2 2012-06-25 12:04:37

cschneider
Talend Team
Registered: 2011-05-27
Posts: 23
Website

Re: sl4j or log4j logging

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.

Offline

#3 2012-06-25 12:56:44

vnodkmar
Member
Registered: 2012-02-10
Posts: 31

Re: sl4j or log4j logging

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.

Last edited by vnodkmar (2012-06-25 13:16:45)

Offline

#4 2012-06-25 13:44:13

cschneider
Talend Team
Registered: 2011-05-27
Posts: 23
Website

Re: sl4j or log4j logging

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.

Offline

#5 2012-06-25 15:27:45

vnodkmar
Member
Registered: 2012-02-10
Posts: 31

Re: sl4j or log4j logging

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

Offline

#6 2012-06-25 16:09:38

cschneider
Talend Team
Registered: 2011-05-27
Posts: 23
Website

Re: sl4j or log4j logging

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.

Offline

#7 2012-06-27 19:20:30

eost
Talend Team
Registered: 2010-12-07
Posts: 241

Re: sl4j or log4j logging

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.

Offline

#8 2012-06-27 19:57:42

eost
Talend Team
Registered: 2010-12-07
Posts: 241

Re: sl4j or log4j logging

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

Offline

Board footer

Powered by FluxBB