AOP Logging: @Aspect is not logging the error in console for log4j default configurationLog4J 2 properties configuration not workingThe @AfterThrowing advice is not executedLog4j-2.6.2 Basic Configurator is not configuring the logging levelshow to print specific class logs which mentioned in log4j properties file using spring AOPHow to log exception details in Spring AOP with try with empty catch block?Probleme in AOP configuration seems to be invalidSpring MVC + Log4j2 defining log4j2.properties file in none class path location not identifiedlog4j2 - StatusLogger No Log4j 2 configuration file found. Using default configurationjava setProperty for log4j.configurationFile not workHow to use default logging configuration of wildfly12(standaloneconfigurationlogging.properties) instead log4j2.properties?

Increase speed altering column on large table to NON NULL

Is there a DSLR/mirorless camera with minimal options like a classic, simple SLR?

Write a function that checks if a string starts with or contains something

Rail-to-rail op-amp only reaches 90% of VCC, works sometimes, not everytime

How to avoid typing 'git' at the begining of every Git command

What differences exist between adamantine and adamantite in all editions of D&D?

Who won a Game of Bar Dice?

Grep Match and extract

Is it possible to fly backward if you have really strong headwind?

Who voices the small round football sized demon in Good Omens?

Confused with atmospheric pressure equals plastic balloon’s inner pressure

Should I refuse to be named as co-author of a low quality paper?

What is the Leave No Trace way to dispose of coffee grounds?

Does the Nuka-Cola bottler actually generate nuka cola?

Can a human be transformed into a Mind Flayer?

A word that means "blending into a community too much"

What should I discuss with my DM prior to my first game?

Was planting UN flag on Moon ever discussed?

Who is "He that flies" in Lord of the Rings?

What is the logic behind charging tax _in the form of money_ for owning property when the property does not produce money?

Why did the World Bank set the global poverty line at $1.90?

Math cases align being colored as a table

Why was this person allowed to become Grand Maester?

Why is long-term living in Almost-Earth causing severe health problems?



AOP Logging: @Aspect is not logging the error in console for log4j default configuration


Log4J 2 properties configuration not workingThe @AfterThrowing advice is not executedLog4j-2.6.2 Basic Configurator is not configuring the logging levelshow to print specific class logs which mentioned in log4j properties file using spring AOPHow to log exception details in Spring AOP with try with empty catch block?Probleme in AOP configuration seems to be invalidSpring MVC + Log4j2 defining log4j2.properties file in none class path location not identifiedlog4j2 - StatusLogger No Log4j 2 configuration file found. Using default configurationjava setProperty for log4j.configurationFile not workHow to use default logging configuration of wildfly12(standaloneconfigurationlogging.properties) instead log4j2.properties?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I'm new to Spring and trying to implement Spring AOP using log4j to log errors in console.
Please note that I don't have log4j.xml in my project but that should be fine as I just want to log the error in the console using Spring AOP concept.



Below is my code and when I run this, I can see the Exception stack trace in the console but I don't see my LoggingAspect.java is logging the error in the console as it should be.



I've tried adding a static block in LoggingAspect.java to print some text in the console using System.out.println(), but it's not printing.



SpringConfig.java



package exercise5.com.aadi.configuration;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

@Configuration
@EnableAspectJAutoProxy
@ComponentScan(basePackages = "exercise5.com.aadi.service")
public class SpringConfig



LoggingAspect.java



package exercise5.com.aadi.utility;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;


@Aspect
@Component
public class LoggingAspect

@AfterThrowing(pointcut = "execution(* exercise5.com.aadi.service.*Impl.*(..))", throwing = "exception")
public void logExceptionFromService(Exception exception) throws Exception
Logger logger = LogManager.getLogger(this.getClass());
logger.error(exception);




My Exception is coming from DAO



InsuranceServiceImpl.java



package exercise5.com.aadi.service;

...
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

...

@Service(value = "insuranceService")
public class InsuranceServiceImpl implements InsuranceService

...

@Override
public List<PolicyReport> getReport(String policyType) throws Exception
...

if (filteredPolicy.isEmpty())
throw new Exception("Service.NO_RECORD");

...



...



Below is the console message I'm getting



ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2
Exception in thread "main" java.lang.Exception: Service.NO_RECORD
at exercise5.com.aadi.service.InsuranceServiceImpl.getReport(InsuranceServiceImpl.java:43)
at exercise5.com.aadi.ui.UserInterface.generateReport(UserInterface.java:45)
at exercise5.com.aadi.ui.UserInterface.main(UserInterface.java:20)


But what I'm expecting is



ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2
Exception in thread "main" 02:03:52.656 [main] ERROR exercise5.com.aadi.service.InsuranceServiceImpl
java.lang.Exception: Service.NO_RECORD
at exercise5.com.aadi.service.InsuranceServiceImpl.getReport(InsuranceServiceImpl.java:56) [bin/:?]
at exercise5.com.aadi.ui.UserInterface.generateReport(UserInterface.java:45) [bin/:?]
at exercise5.com.aadi.ui.UserInterface.main(UserInterface.java:20) [bin/:?]
java.lang.Exception: Service.NO_RECORD
at exercise5.com.aadi.service.InsuranceServiceImpl.getReport(InsuranceServiceImpl.java:56)
at exercise5.com.aadi.ui.UserInterface.generateReport(UserInterface.java:45)
at exercise5.com.aadi.ui.UserInterface.main(UserInterface.java:20)


Note that two times the Exception Log should be there. First one from Spring AOP LoggingAspect.java and the second one is the normal Exception stack trace.



Anyone can help me out, why I'm not getting the first one?










share|improve this question




























    1















    I'm new to Spring and trying to implement Spring AOP using log4j to log errors in console.
    Please note that I don't have log4j.xml in my project but that should be fine as I just want to log the error in the console using Spring AOP concept.



    Below is my code and when I run this, I can see the Exception stack trace in the console but I don't see my LoggingAspect.java is logging the error in the console as it should be.



    I've tried adding a static block in LoggingAspect.java to print some text in the console using System.out.println(), but it's not printing.



    SpringConfig.java



    package exercise5.com.aadi.configuration;

    import org.springframework.context.annotation.ComponentScan;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.context.annotation.EnableAspectJAutoProxy;

    @Configuration
    @EnableAspectJAutoProxy
    @ComponentScan(basePackages = "exercise5.com.aadi.service")
    public class SpringConfig



    LoggingAspect.java



    package exercise5.com.aadi.utility;

    import org.apache.logging.log4j.LogManager;
    import org.apache.logging.log4j.Logger;
    import org.aspectj.lang.annotation.AfterThrowing;
    import org.aspectj.lang.annotation.Aspect;
    import org.springframework.stereotype.Component;


    @Aspect
    @Component
    public class LoggingAspect

    @AfterThrowing(pointcut = "execution(* exercise5.com.aadi.service.*Impl.*(..))", throwing = "exception")
    public void logExceptionFromService(Exception exception) throws Exception
    Logger logger = LogManager.getLogger(this.getClass());
    logger.error(exception);




    My Exception is coming from DAO



    InsuranceServiceImpl.java



    package exercise5.com.aadi.service;

    ...
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;

    ...

    @Service(value = "insuranceService")
    public class InsuranceServiceImpl implements InsuranceService

    ...

    @Override
    public List<PolicyReport> getReport(String policyType) throws Exception
    ...

    if (filteredPolicy.isEmpty())
    throw new Exception("Service.NO_RECORD");

    ...



    ...



    Below is the console message I'm getting



    ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2
    Exception in thread "main" java.lang.Exception: Service.NO_RECORD
    at exercise5.com.aadi.service.InsuranceServiceImpl.getReport(InsuranceServiceImpl.java:43)
    at exercise5.com.aadi.ui.UserInterface.generateReport(UserInterface.java:45)
    at exercise5.com.aadi.ui.UserInterface.main(UserInterface.java:20)


    But what I'm expecting is



    ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2
    Exception in thread "main" 02:03:52.656 [main] ERROR exercise5.com.aadi.service.InsuranceServiceImpl
    java.lang.Exception: Service.NO_RECORD
    at exercise5.com.aadi.service.InsuranceServiceImpl.getReport(InsuranceServiceImpl.java:56) [bin/:?]
    at exercise5.com.aadi.ui.UserInterface.generateReport(UserInterface.java:45) [bin/:?]
    at exercise5.com.aadi.ui.UserInterface.main(UserInterface.java:20) [bin/:?]
    java.lang.Exception: Service.NO_RECORD
    at exercise5.com.aadi.service.InsuranceServiceImpl.getReport(InsuranceServiceImpl.java:56)
    at exercise5.com.aadi.ui.UserInterface.generateReport(UserInterface.java:45)
    at exercise5.com.aadi.ui.UserInterface.main(UserInterface.java:20)


    Note that two times the Exception Log should be there. First one from Spring AOP LoggingAspect.java and the second one is the normal Exception stack trace.



    Anyone can help me out, why I'm not getting the first one?










    share|improve this question
























      1












      1








      1








      I'm new to Spring and trying to implement Spring AOP using log4j to log errors in console.
      Please note that I don't have log4j.xml in my project but that should be fine as I just want to log the error in the console using Spring AOP concept.



      Below is my code and when I run this, I can see the Exception stack trace in the console but I don't see my LoggingAspect.java is logging the error in the console as it should be.



      I've tried adding a static block in LoggingAspect.java to print some text in the console using System.out.println(), but it's not printing.



      SpringConfig.java



      package exercise5.com.aadi.configuration;

      import org.springframework.context.annotation.ComponentScan;
      import org.springframework.context.annotation.Configuration;
      import org.springframework.context.annotation.EnableAspectJAutoProxy;

      @Configuration
      @EnableAspectJAutoProxy
      @ComponentScan(basePackages = "exercise5.com.aadi.service")
      public class SpringConfig



      LoggingAspect.java



      package exercise5.com.aadi.utility;

      import org.apache.logging.log4j.LogManager;
      import org.apache.logging.log4j.Logger;
      import org.aspectj.lang.annotation.AfterThrowing;
      import org.aspectj.lang.annotation.Aspect;
      import org.springframework.stereotype.Component;


      @Aspect
      @Component
      public class LoggingAspect

      @AfterThrowing(pointcut = "execution(* exercise5.com.aadi.service.*Impl.*(..))", throwing = "exception")
      public void logExceptionFromService(Exception exception) throws Exception
      Logger logger = LogManager.getLogger(this.getClass());
      logger.error(exception);




      My Exception is coming from DAO



      InsuranceServiceImpl.java



      package exercise5.com.aadi.service;

      ...
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.stereotype.Service;

      ...

      @Service(value = "insuranceService")
      public class InsuranceServiceImpl implements InsuranceService

      ...

      @Override
      public List<PolicyReport> getReport(String policyType) throws Exception
      ...

      if (filteredPolicy.isEmpty())
      throw new Exception("Service.NO_RECORD");

      ...



      ...



      Below is the console message I'm getting



      ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2
      Exception in thread "main" java.lang.Exception: Service.NO_RECORD
      at exercise5.com.aadi.service.InsuranceServiceImpl.getReport(InsuranceServiceImpl.java:43)
      at exercise5.com.aadi.ui.UserInterface.generateReport(UserInterface.java:45)
      at exercise5.com.aadi.ui.UserInterface.main(UserInterface.java:20)


      But what I'm expecting is



      ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2
      Exception in thread "main" 02:03:52.656 [main] ERROR exercise5.com.aadi.service.InsuranceServiceImpl
      java.lang.Exception: Service.NO_RECORD
      at exercise5.com.aadi.service.InsuranceServiceImpl.getReport(InsuranceServiceImpl.java:56) [bin/:?]
      at exercise5.com.aadi.ui.UserInterface.generateReport(UserInterface.java:45) [bin/:?]
      at exercise5.com.aadi.ui.UserInterface.main(UserInterface.java:20) [bin/:?]
      java.lang.Exception: Service.NO_RECORD
      at exercise5.com.aadi.service.InsuranceServiceImpl.getReport(InsuranceServiceImpl.java:56)
      at exercise5.com.aadi.ui.UserInterface.generateReport(UserInterface.java:45)
      at exercise5.com.aadi.ui.UserInterface.main(UserInterface.java:20)


      Note that two times the Exception Log should be there. First one from Spring AOP LoggingAspect.java and the second one is the normal Exception stack trace.



      Anyone can help me out, why I'm not getting the first one?










      share|improve this question














      I'm new to Spring and trying to implement Spring AOP using log4j to log errors in console.
      Please note that I don't have log4j.xml in my project but that should be fine as I just want to log the error in the console using Spring AOP concept.



      Below is my code and when I run this, I can see the Exception stack trace in the console but I don't see my LoggingAspect.java is logging the error in the console as it should be.



      I've tried adding a static block in LoggingAspect.java to print some text in the console using System.out.println(), but it's not printing.



      SpringConfig.java



      package exercise5.com.aadi.configuration;

      import org.springframework.context.annotation.ComponentScan;
      import org.springframework.context.annotation.Configuration;
      import org.springframework.context.annotation.EnableAspectJAutoProxy;

      @Configuration
      @EnableAspectJAutoProxy
      @ComponentScan(basePackages = "exercise5.com.aadi.service")
      public class SpringConfig



      LoggingAspect.java



      package exercise5.com.aadi.utility;

      import org.apache.logging.log4j.LogManager;
      import org.apache.logging.log4j.Logger;
      import org.aspectj.lang.annotation.AfterThrowing;
      import org.aspectj.lang.annotation.Aspect;
      import org.springframework.stereotype.Component;


      @Aspect
      @Component
      public class LoggingAspect

      @AfterThrowing(pointcut = "execution(* exercise5.com.aadi.service.*Impl.*(..))", throwing = "exception")
      public void logExceptionFromService(Exception exception) throws Exception
      Logger logger = LogManager.getLogger(this.getClass());
      logger.error(exception);




      My Exception is coming from DAO



      InsuranceServiceImpl.java



      package exercise5.com.aadi.service;

      ...
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.stereotype.Service;

      ...

      @Service(value = "insuranceService")
      public class InsuranceServiceImpl implements InsuranceService

      ...

      @Override
      public List<PolicyReport> getReport(String policyType) throws Exception
      ...

      if (filteredPolicy.isEmpty())
      throw new Exception("Service.NO_RECORD");

      ...



      ...



      Below is the console message I'm getting



      ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2
      Exception in thread "main" java.lang.Exception: Service.NO_RECORD
      at exercise5.com.aadi.service.InsuranceServiceImpl.getReport(InsuranceServiceImpl.java:43)
      at exercise5.com.aadi.ui.UserInterface.generateReport(UserInterface.java:45)
      at exercise5.com.aadi.ui.UserInterface.main(UserInterface.java:20)


      But what I'm expecting is



      ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2
      Exception in thread "main" 02:03:52.656 [main] ERROR exercise5.com.aadi.service.InsuranceServiceImpl
      java.lang.Exception: Service.NO_RECORD
      at exercise5.com.aadi.service.InsuranceServiceImpl.getReport(InsuranceServiceImpl.java:56) [bin/:?]
      at exercise5.com.aadi.ui.UserInterface.generateReport(UserInterface.java:45) [bin/:?]
      at exercise5.com.aadi.ui.UserInterface.main(UserInterface.java:20) [bin/:?]
      java.lang.Exception: Service.NO_RECORD
      at exercise5.com.aadi.service.InsuranceServiceImpl.getReport(InsuranceServiceImpl.java:56)
      at exercise5.com.aadi.ui.UserInterface.generateReport(UserInterface.java:45)
      at exercise5.com.aadi.ui.UserInterface.main(UserInterface.java:20)


      Note that two times the Exception Log should be there. First one from Spring AOP LoggingAspect.java and the second one is the normal Exception stack trace.



      Anyone can help me out, why I'm not getting the first one?







      java spring logging spring-aop






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 24 at 20:54









      AadiAadi

      83




      83






















          1 Answer
          1






          active

          oldest

          votes


















          0














          You're specifying



          @ComponentScan(basePackages = "exercise5.com.aadi.service")


          Which means your LoggingAspect @Component won't be picked up by Spring, because it lives under



          exercise5.com.aadi.utility


          Other than that your AOP configuration seems on point.






          share|improve this answer























          • Thanks a lot. It fixed the issue when I added the LoggingAspect class' package under basePackages of SpringConfig class.

            – Aadi
            Mar 25 at 20:22











          • @Aadi awesome! Thanks for the promptly accept ;)

            – LppEdd
            Mar 25 at 20:24











          • Though I'm having another issue. ctx.getBean(InsuranceServiceImpl.class) is giving me NoSuchBeanDefinitionException. whereas ctx.getBean("insuranceService") is working absolutely fine. Any clue?

            – Aadi
            Mar 25 at 20:25











          • @Aadi InsuranceServiceImpl seems like a concrete implementation, Maybe you need to ask for the relative base interface.

            – LppEdd
            Mar 25 at 20:26












          • Wow! can't believe. It fixed when I add ctx.getBean(InsuranceService.class). You are a genius. Thanks a lot. But I don't get the reason why InsuranceServiceImpl.class did not work? In which scenario do I need to do like getBean(...Service.class)? or getBean(....ServiceImpl.class) is always wrong?

            – Aadi
            Mar 25 at 20:33











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55328480%2faop-logging-aspect-is-not-logging-the-error-in-console-for-log4j-default-confi%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You're specifying



          @ComponentScan(basePackages = "exercise5.com.aadi.service")


          Which means your LoggingAspect @Component won't be picked up by Spring, because it lives under



          exercise5.com.aadi.utility


          Other than that your AOP configuration seems on point.






          share|improve this answer























          • Thanks a lot. It fixed the issue when I added the LoggingAspect class' package under basePackages of SpringConfig class.

            – Aadi
            Mar 25 at 20:22











          • @Aadi awesome! Thanks for the promptly accept ;)

            – LppEdd
            Mar 25 at 20:24











          • Though I'm having another issue. ctx.getBean(InsuranceServiceImpl.class) is giving me NoSuchBeanDefinitionException. whereas ctx.getBean("insuranceService") is working absolutely fine. Any clue?

            – Aadi
            Mar 25 at 20:25











          • @Aadi InsuranceServiceImpl seems like a concrete implementation, Maybe you need to ask for the relative base interface.

            – LppEdd
            Mar 25 at 20:26












          • Wow! can't believe. It fixed when I add ctx.getBean(InsuranceService.class). You are a genius. Thanks a lot. But I don't get the reason why InsuranceServiceImpl.class did not work? In which scenario do I need to do like getBean(...Service.class)? or getBean(....ServiceImpl.class) is always wrong?

            – Aadi
            Mar 25 at 20:33















          0














          You're specifying



          @ComponentScan(basePackages = "exercise5.com.aadi.service")


          Which means your LoggingAspect @Component won't be picked up by Spring, because it lives under



          exercise5.com.aadi.utility


          Other than that your AOP configuration seems on point.






          share|improve this answer























          • Thanks a lot. It fixed the issue when I added the LoggingAspect class' package under basePackages of SpringConfig class.

            – Aadi
            Mar 25 at 20:22











          • @Aadi awesome! Thanks for the promptly accept ;)

            – LppEdd
            Mar 25 at 20:24











          • Though I'm having another issue. ctx.getBean(InsuranceServiceImpl.class) is giving me NoSuchBeanDefinitionException. whereas ctx.getBean("insuranceService") is working absolutely fine. Any clue?

            – Aadi
            Mar 25 at 20:25











          • @Aadi InsuranceServiceImpl seems like a concrete implementation, Maybe you need to ask for the relative base interface.

            – LppEdd
            Mar 25 at 20:26












          • Wow! can't believe. It fixed when I add ctx.getBean(InsuranceService.class). You are a genius. Thanks a lot. But I don't get the reason why InsuranceServiceImpl.class did not work? In which scenario do I need to do like getBean(...Service.class)? or getBean(....ServiceImpl.class) is always wrong?

            – Aadi
            Mar 25 at 20:33













          0












          0








          0







          You're specifying



          @ComponentScan(basePackages = "exercise5.com.aadi.service")


          Which means your LoggingAspect @Component won't be picked up by Spring, because it lives under



          exercise5.com.aadi.utility


          Other than that your AOP configuration seems on point.






          share|improve this answer













          You're specifying



          @ComponentScan(basePackages = "exercise5.com.aadi.service")


          Which means your LoggingAspect @Component won't be picked up by Spring, because it lives under



          exercise5.com.aadi.utility


          Other than that your AOP configuration seems on point.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 24 at 21:07









          LppEddLppEdd

          10.3k31949




          10.3k31949












          • Thanks a lot. It fixed the issue when I added the LoggingAspect class' package under basePackages of SpringConfig class.

            – Aadi
            Mar 25 at 20:22











          • @Aadi awesome! Thanks for the promptly accept ;)

            – LppEdd
            Mar 25 at 20:24











          • Though I'm having another issue. ctx.getBean(InsuranceServiceImpl.class) is giving me NoSuchBeanDefinitionException. whereas ctx.getBean("insuranceService") is working absolutely fine. Any clue?

            – Aadi
            Mar 25 at 20:25











          • @Aadi InsuranceServiceImpl seems like a concrete implementation, Maybe you need to ask for the relative base interface.

            – LppEdd
            Mar 25 at 20:26












          • Wow! can't believe. It fixed when I add ctx.getBean(InsuranceService.class). You are a genius. Thanks a lot. But I don't get the reason why InsuranceServiceImpl.class did not work? In which scenario do I need to do like getBean(...Service.class)? or getBean(....ServiceImpl.class) is always wrong?

            – Aadi
            Mar 25 at 20:33

















          • Thanks a lot. It fixed the issue when I added the LoggingAspect class' package under basePackages of SpringConfig class.

            – Aadi
            Mar 25 at 20:22











          • @Aadi awesome! Thanks for the promptly accept ;)

            – LppEdd
            Mar 25 at 20:24











          • Though I'm having another issue. ctx.getBean(InsuranceServiceImpl.class) is giving me NoSuchBeanDefinitionException. whereas ctx.getBean("insuranceService") is working absolutely fine. Any clue?

            – Aadi
            Mar 25 at 20:25











          • @Aadi InsuranceServiceImpl seems like a concrete implementation, Maybe you need to ask for the relative base interface.

            – LppEdd
            Mar 25 at 20:26












          • Wow! can't believe. It fixed when I add ctx.getBean(InsuranceService.class). You are a genius. Thanks a lot. But I don't get the reason why InsuranceServiceImpl.class did not work? In which scenario do I need to do like getBean(...Service.class)? or getBean(....ServiceImpl.class) is always wrong?

            – Aadi
            Mar 25 at 20:33
















          Thanks a lot. It fixed the issue when I added the LoggingAspect class' package under basePackages of SpringConfig class.

          – Aadi
          Mar 25 at 20:22





          Thanks a lot. It fixed the issue when I added the LoggingAspect class' package under basePackages of SpringConfig class.

          – Aadi
          Mar 25 at 20:22













          @Aadi awesome! Thanks for the promptly accept ;)

          – LppEdd
          Mar 25 at 20:24





          @Aadi awesome! Thanks for the promptly accept ;)

          – LppEdd
          Mar 25 at 20:24













          Though I'm having another issue. ctx.getBean(InsuranceServiceImpl.class) is giving me NoSuchBeanDefinitionException. whereas ctx.getBean("insuranceService") is working absolutely fine. Any clue?

          – Aadi
          Mar 25 at 20:25





          Though I'm having another issue. ctx.getBean(InsuranceServiceImpl.class) is giving me NoSuchBeanDefinitionException. whereas ctx.getBean("insuranceService") is working absolutely fine. Any clue?

          – Aadi
          Mar 25 at 20:25













          @Aadi InsuranceServiceImpl seems like a concrete implementation, Maybe you need to ask for the relative base interface.

          – LppEdd
          Mar 25 at 20:26






          @Aadi InsuranceServiceImpl seems like a concrete implementation, Maybe you need to ask for the relative base interface.

          – LppEdd
          Mar 25 at 20:26














          Wow! can't believe. It fixed when I add ctx.getBean(InsuranceService.class). You are a genius. Thanks a lot. But I don't get the reason why InsuranceServiceImpl.class did not work? In which scenario do I need to do like getBean(...Service.class)? or getBean(....ServiceImpl.class) is always wrong?

          – Aadi
          Mar 25 at 20:33





          Wow! can't believe. It fixed when I add ctx.getBean(InsuranceService.class). You are a genius. Thanks a lot. But I don't get the reason why InsuranceServiceImpl.class did not work? In which scenario do I need to do like getBean(...Service.class)? or getBean(....ServiceImpl.class) is always wrong?

          – Aadi
          Mar 25 at 20:33



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55328480%2faop-logging-aspect-is-not-logging-the-error-in-console-for-log4j-default-confi%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript