Dmytro Titov
Dmytro Titov

Reputation: 3201

Disable AppClassLoader AspectJ logging with Spring Boot

My question is very similar to this one: Suppressing logs from AppClassLoader

The difference is that I'm using AspectJ with Spring Boot (via @EnableAspectJAutoProxy and @EnableLoadTimeWeaving(aspectjWeaving = ENABLED) annotations), so I have neither META-INF/aop.xml, nor META-INF/aop-ajc.xml files, which are mentioned in the answer there.

How do I disable these annoying AppClassLoader warnings with annotation-based configuration?

Update Just to clarify, I'm talking about this kind of logs:

...
[AppClassLoader@18b4aac2] error can't determine implemented interfaces of missing type org.springframework.cache.ehcache.EhCacheCacheManager
when weaving type org.springframework.boot.autoconfigure.cache.EhCacheCacheConfiguration
when weaving classes 
when weaving 
 [Xlint:cantFindType]
[AppClassLoader@18b4aac2] error can't determine implemented interfaces of missing type org.springframework.cache.ehcache.EhCacheCacheManager
when weaving type org.springframework.boot.autoconfigure.cache.EhCacheCacheConfiguration
when weaving classes 
when weaving 
 [Xlint:cantFindType]
[AppClassLoader@18b4aac2] error can't determine implemented interfaces of missing type org.springframework.cache.ehcache.EhCacheCacheManager
when weaving type org.springframework.boot.autoconfigure.cache.EhCacheCacheConfiguration
when weaving classes 
when weaving 
...

They are printed in red and there's A LOT of them. So I want to suppress these logs somehow.

Upvotes: 1

Views: 2451

Answers (1)

Nándor Előd Fekete
Nándor Előd Fekete

Reputation: 7098

In order to suppress some of the AspectJ compiler messages while using AspectJ load-time weaving, you can do the following.

Create a copy of the file aspectjweaver.jar!/org/aspectj/weaver/XlintDefault.properties to your resources/META-INF folder with the name Xlint.properties.

Change the line

cantFindType = error

to

cantFindType = ignore

Then, create your aop.xml in your resources/META-INF folder as follows, or add the corresponding option to the <weaver> entry as shown:

<!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN"
        "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
<aspectj>
    <weaver options="-Xlintfile:META-INF/Xlint.properties" />
</aspectj>

Now you should have your cantFindType errors suppressed, but other AspectJ messages left alone. You can change the reporting of other linter messages similarly.

Upvotes: 2

Related Questions