tag:blogger.com,1999:blog-2302252496976792766.post7814196445683957709..comments2022-04-06T04:25:23.348+05:30Comments on Java Geeks: Auto Injection of a Logger into Spring beansShirish Pandharikarhttp://www.blogger.com/profile/08711504385122792110noreply@blogger.comBlogger14125tag:blogger.com,1999:blog-2302252496976792766.post-91910073587492970962021-08-08T19:20:49.549+05:302021-08-08T19:20:49.549+05:30This is a very old post and I would simply recomme...This is a very old post and I would simply recommend using Lombok and annotate you class with @Slf4j and one of logger annotations you want to use.Shirish Pandharikarhttps://www.blogger.com/profile/08711504385122792110noreply@blogger.comtag:blogger.com,1999:blog-2302252496976792766.post-6478171621198393662015-02-26T18:31:18.149+05:302015-02-26T18:31:18.149+05:30Maybe it could be interesting for somebody: https:...Maybe it could be interesting for somebody: https://github.com/vbauer/heraldhaM3rhttps://www.blogger.com/profile/09592405036138436406noreply@blogger.comtag:blogger.com,1999:blog-2302252496976792766.post-35167424854879698892012-09-06T19:19:03.192+05:302012-09-06T19:19:03.192+05:30I mean: if you want to initialize a static field b...I mean: if you want to initialize a static field before the first instance is created. The above example in the blog can be modified to work for static fields as well. It will initialize the static logger and is available in the constructor, except when the constructor runs the first time.Verhás Péterhttps://www.blogger.com/profile/06377161363854132582noreply@blogger.comtag:blogger.com,1999:blog-2302252496976792766.post-12379371947262839232012-09-06T19:16:12.211+05:302012-09-06T19:16:12.211+05:30If you want to have a static field intialized you ...If you want to have a static field intialized you can do that outside of spring. Create a class loader, that uses the original classloader to load the class and after that fills in the static fields.Verhás Péterhttps://www.blogger.com/profile/06377161363854132582noreply@blogger.comtag:blogger.com,1999:blog-2302252496976792766.post-11530358674927494032012-08-14T18:32:57.219+05:302012-08-14T18:32:57.219+05:30I did everything you wrote here. For a few classes...I did everything you wrote here. For a few classes the logger was injected but then there are few classes with logger = null. In a console output I got this (shortened):<br /><br />Bean 'XYZ' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying).<br /><br />I think this is cause of my NPEs, because logger was never processed by Injector class. Do anybody know anything that could help? I am grateful for every advice. Thank you.Matejhttps://www.blogger.com/profile/10358023108270747913noreply@blogger.comtag:blogger.com,1999:blog-2302252496976792766.post-34462999924591672532011-05-18T20:18:43.202+05:302011-05-18T20:18:43.202+05:30Mein Gott you have simplified my logging life sir....Mein Gott you have simplified my logging life sir. One of those snippets that I can easily understand how it's done, but would not have thought to do it myself.jhettenhhttps://www.blogger.com/profile/07615978871088415550noreply@blogger.comtag:blogger.com,1999:blog-2302252496976792766.post-29896127741653260422011-04-20T16:39:08.421+05:302011-04-20T16:39:08.421+05:30Nice.. Thanks!Nice.. Thanks!Shirishnoreply@blogger.comtag:blogger.com,1999:blog-2302252496976792766.post-37751567270231685472011-03-11T18:12:55.827+05:302011-03-11T18:12:55.827+05:30@Autowired :)@Autowired :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2302252496976792766.post-16086601873375841142011-03-10T16:54:51.123+05:302011-03-10T16:54:51.123+05:30@Vels: Your example gives a picture of how to use ...@Vels: Your example gives a picture of how to use Aspects for logging. This is a good approach only if logging is required during the AOP supported methods e.g. Before, After, etc. It cannot be used to log some information within the method body as such.Shirish Pandharikarhttps://www.blogger.com/profile/08711504385122792110noreply@blogger.comtag:blogger.com,1999:blog-2302252496976792766.post-38228274610680889952011-02-05T07:42:09.515+05:302011-02-05T07:42:09.515+05:30Spring dependency injection works on normal jvm, s...Spring dependency injection works on normal jvm, so Spring creates object and then inject dependencies throught properties. The only method to use logger in constructor is pass it throught constructor-args.<br />You can try to make proxies using AspectJ/Spring AOP and then inject logger into constructor of real object.<br />IMHO, it not neccessary.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2302252496976792766.post-80119082915895015662010-11-23T17:29:44.268+05:302010-11-23T17:29:44.268+05:30Good article.....
To implement Logger using Sprin...Good article.....<br /><br />To implement Logger using Spring AOP with simple steps ...you can find here <br />http://velmurugan-pousel.blogspot.com/2010/11/logger-example-using-spring-aop.htmlpouselhttps://www.blogger.com/profile/01166900953835600433noreply@blogger.comtag:blogger.com,1999:blog-2302252496976792766.post-3394572991439873002010-02-11T13:02:16.081+05:302010-02-11T13:02:16.081+05:30Did anyone figure out an annotation injection appr...Did anyone figure out an annotation injection approach which would work in constructors or even static blocks? I notice that lipidlog has a java agent classloader approach but I would prefer a spring injection approach if possible. <br />SimonAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-2302252496976792766.post-79962535156774127792009-04-21T00:32:00.000+05:302009-04-21T00:32:00.000+05:30Im wondering about the same thing. I have som logg...Im wondering about the same thing. I have som logging I want to perform in some of my constructorsMhttps://www.blogger.com/profile/17054770204384998554noreply@blogger.comtag:blogger.com,1999:blog-2302252496976792766.post-50109949243601047072009-04-03T13:30:00.000+05:302009-04-03T13:30:00.000+05:30This works great. However logger can't be used in ...This works great. However logger can't be used in the constructor (logger is null). How can it be modified to work also in constructors?cecchisandronehttps://www.blogger.com/profile/03397157027926513216noreply@blogger.com