[resolved] Logging in tJava

One Star

[resolved] Logging in tJava

I have some logic written in tJava. how can I add logging(logger) in tJava component? with info,warning levels

Accepted Solutions

Re: [resolved] Logging in tJava

very possible.
first you need to use a tLog4jInit to create your logger object. Look at the generated code to get the name of the object.
once you have the object, you can send log messages to it directly in code by:
<logger_name>.info("this is an info message");

All Replies
Community Manager

Re: [resolved] Logging in tJava

Hi ashu
I think you can reference tLog4j component and its source code.
http://www.talendforge.org/exchange/tos/extension_view.php?eid=211
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Logging in tJava

Thanks Shong.
I downloaded the Revision 1.3 of tLog4J component and extracted the ZIP file. from my TDQ studio window->preferences->Talend->Components. I added the unzipped folder as UserComponents, also in tLog4J_java.xml updated the Family, restarted the studio. but I don't see the new component added to the palette. is I'm missing any thing in installing this component???
<FAMILIES>
<FAMILY>Logs_Errors</FAMILY>
<FAMILY>Logs_Errors/Log4J</FAMILY>
</FAMILIES>
One Star

Re: [resolved] Logging in tJava

after placing the log4j directory in \plugins\org.talend.designer.components.localprovider_<version>\components I can see the log4J component available in Palette. Thanks
I have 1400 lines of Java code written in tJava component Smiley Sad . how to add a logger in that code? is it possible?

Re: [resolved] Logging in tJava

very possible.
first you need to use a tLog4jInit to create your logger object. Look at the generated code to get the name of the object.
once you have the object, you can send log messages to it directly in code by:
<logger_name>.info("this is an info message");
One Star

Re: [resolved] Logging in tJava

Thanks JohnGarrettMartin
One Star

Re: [resolved] Logging in tJava

Hello, 
There are other solution. Add in your tJava :
org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(this.getClass());
logger.info("In your message !!!");