-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@Loggable does not work #256
Comments
@yegor256 please, pay attention to this issue |
Called function with @loggable from another project, it works. |
I use Java 8 + Springboot 1.4.7 + Lombok + home made AspectJ, working on a project with 691 classes, and sometimes it works, sometimes it doesn't. I really would like to know how to debug that, but I have no clue of how to do it. |
I am also playing a bit around with this issue. What I found out is that you have to apply the versions of aspectjrt / jcabi-aspects also to the maven plugin: <plugin>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-maven-plugin</artifactId>
<version>0.14</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<execution>
<goals>
<goal>ajc</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-aspects</artifactId>
<version>0.22.6</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.9.1</version>
</dependency>
</dependencies>
</plugin> jcabi-maven-plugin 0.14.1 is causing an issue within m2e so I reverted it to 0.14. If you don't set the dependency java 1.6 and an old jcabi version is used. mvn clean package -X I was also not able to make this running. Looking forward for some new infos here. 👍 |
The lib "jcabi-aspects" already draws the dependency to the lib "aspectjrt". |
Hi @Maze-fr - thanks for the information. I changed my pom.xml like this: <build>
<plugins>
<plugin>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-maven-plugin</artifactId>
<version>0.14</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<execution>
<goals>
<goal>ajc</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-aspects</artifactId>
<version>0.22.6</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-aspects</artifactId>
<version>0.22.6</version>
</dependency>
</dependencies> mvn clean package output:
Seems that somehow the @Loggable(Loggable.DEBUG) are not discovered. |
Yes, I have the same problem : it says that everything is scanned, but it finds no @loggable |
@Maze-fr try this: @com.jcabi.aspects.Loggable(value=com.jcabi.aspects.Loggable.DEBUG) There are several issues. One is that somehow the compiler doesn't use the right import in my case. That was the reason why the annotation wasn't detected. It imports something jdk.nashorn...Loggable. Glad to have JD installed 😄 The next issue is that the maven plugin doesn't show the right outputs. I think this should investigated by the authors of this plugin. |
I guess this is a compiler issue, because the import is not considered to be used. There are to ways of fixing this:
Hope this helps. |
I may have a clue... As I was a little upset of not being able to log with When doing that, I noticed that my But it created another problem, which is complex for me to explain in English, so I hope you will manage to understand. Once that problem solved, my own "loggable" aspect works very well, and I log the same way we do with Based on that, I thought that I could solve my problem with @Bean
public MethodLogger methodLogger() {
// return Aspects.aspectOf(MethodLogger.class);
// return MethodLogger.aspectOf();
return new MethodLogger();
} But it doesn't work... it's not recognised as an aspect by Spring AOP. So I wanted to try another solution... But I don't like to clone code, so if you want to make /**
* The Class SpringMethodLogger makes {@link Loggable} working in Spring proxies.
*/
@Aspect
@Component
@NoArgsConstructor
public class SpringMethodLogger {
private static final MethodLogger METHOD_LOGGER = Optional.ofNullable(MethodLogger.aspectOf())
.orElse(new MethodLogger());
@Around("execution(public * (@com.jcabi.aspects.Loggable *).*(..))"
+ " && !execution(String *.toString())"
+ " && !execution(int *.hashCode())"
+ " && !execution(boolean *.canEqual(Object))"
+ " && !execution(boolean *.equals(Object))")
public Object wrapClass(final ProceedingJoinPoint point) throws Throwable {
return METHOD_LOGGER.wrapClass(point);
}
@Around("@annotation(com.jcabi.aspects.Loggable)")
public Object wrapMethod(final ProceedingJoinPoint point) throws Throwable {
return METHOD_LOGGER.wrapMethod(point);
}
} If your |
Does not work on Sring Boot + Gradle and |
pom.xml:
log4j.properties:
Problem: Run with Main in IntelliJ IDEA, logger.debug("mylog") logged correctly, but @loggable logged nothing.
The text was updated successfully, but these errors were encountered: