Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] Logging in tJava

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

Accepted Solutions
Anonymous
Not applicable
Author

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");

View solution in original post

6 Replies
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

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>
Anonymous
Not applicable
Author

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 0683p000009MPcz.png . how to add a logger in that code? is it possible?
Anonymous
Not applicable
Author

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");
Anonymous
Not applicable
Author

Thanks JohnGarrettMartin
cm2d
Contributor
Contributor

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 !!!");