tag:blogger.com,1999:blog-26866996.post214280733309355801..comments2023-05-16T03:14:55.163-05:00Comments on JFKBits: Log4j code template in EclipseUnknownnoreply@blogger.comBlogger4125tag:blogger.com,1999:blog-26866996.post-42069561703746846632009-11-24T17:46:29.867-06:002009-11-24T17:46:29.867-06:00This works for me:
${imp:import(org.apache.log4j.L...This works for me:<br />${imp:import(org.apache.log4j.Logger)}<br />private static final Logger logger = Logger.getLogger(${enclosing_type}.class);Unknownhttps://www.blogger.com/profile/09195672768889742765noreply@blogger.comtag:blogger.com,1999:blog-26866996.post-20158658005003285052008-09-17T09:53:00.000-05:002008-09-17T09:53:00.000-05:00I tried using the "${:import(org.apache.log4j.Logg...I tried using the "${:import(org.apache.log4j.Logger}" and Eclipse told me that the "Template has invalid variable identifiers". Any help as to how to get this to work? I'd love to be able to also add dynamic importing of the package as well to my template. <BR/>Thanks for sharing this template. Even without the "dynamic import" it has already helped me a ton!!Ryan Magnussonhttps://www.blogger.com/profile/10638181188248016771noreply@blogger.comtag:blogger.com,1999:blog-26866996.post-33357994380631701392008-06-12T10:21:00.000-05:002008-06-12T10:21:00.000-05:00I'll do you one better:${:import(org.apache.log4j....I'll do you one better:<BR/><BR/>${:import(org.apache.log4j.Logger)}private static final Logger logger = Logger.getLogger(${enclosing_type}.class);<BR/><BR/>With this template, Eclipse will also insert the import statement, in the correct place. If the import already exists, it will not put in a duplicate.<BR/><BR/>This also differs in that it uses "static final" for the logger, but you can easily edit it to use an instance, instead of class, variable.Jimothyhttps://www.blogger.com/profile/07350195833953100624noreply@blogger.comtag:blogger.com,1999:blog-26866996.post-59584944731116331302008-06-12T10:17:00.000-05:002008-06-12T10:17:00.000-05:00This comment has been removed by the author.Jimothyhttps://www.blogger.com/profile/07350195833953100624noreply@blogger.com