How to hide some logs from spring boot startup

I want to hide any log from 3rd party jar in the spring boot startup log, especially for springfox.documentation because they are creating so many useless logs like CachingOperationNameGenerator

$ java -jar target/app.jar ___________________________________________________________________________________________________________________   APP API   > keep log clean  > [yyyyMMdd:HHmmssSSS][thread][level][message] ___________________________________________________________________________________________________________________   2020-07-15 23:22:14.810  INFO 47784 --- [           main] i.i.c.CaseMarketplaceApplication         : Starting CaseMarketplaceApplication v0.0.1 on LOCAL-PC with PID 47784 2020-07-15 23:22:14.814  INFO 47784 --- [           main] i.i.c.CaseMarketplaceApplication         : No active profile set, falling back to default profiles: default 2020-07-15 23:22:16.869  INFO 47784 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode. 2020-07-15 23:22:17.059  INFO 47784 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 175ms. Found 18 repository interfaces. 2020-07-15 23:22:18.747  INFO 47784 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8081 (http) 2020-07-15 23:22:18.780  INFO 47784 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat] 2020-07-15 23:22:18.781  INFO 47784 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.21] 2020-07-15 23:22:18.884  INFO 47784 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext 2020-07-15 23:22:18.884  INFO 47784 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 4004 ms 2020-07-15 23:22:20.071  INFO 47784 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default...] 2020-07-15 23:22:20.228  INFO 47784 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.3.10.Final} 2020-07-15 23:22:20.231  INFO 47784 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found 2020-07-15 23:22:20.515  INFO 47784 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.0.Final} 2020-07-15 23:22:20.878  INFO 47784 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting... 2020-07-15 23:22:21.322  INFO 47784 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed. 2020-07-15 23:22:21.341  INFO 47784 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL95Dialect 2020-07-15 23:22:31.679  INFO 47784 --- [           main] o.h.e.j.e.i.LobCreatorBuilderImpl        : HHH000421: Disabling contextual LOB creation as hibernate.jdbc.lob.non_contextual_creation is true 2020-07-15 23:22:31.690  INFO 47784 --- [           main] org.hibernate.type.BasicTypeRegistry     : HHH000270: Type registration [java.util.UUID] overrides previous :  2020-07-15 23:22:34.988  INFO 47784 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' 2020-07-15 23:22:35.626  INFO 47784 --- [           main] o.h.h.i.QueryTranslatorFactoryInitiator  : HHH000397: Using ASTQueryTranslatorFactory 2020-07-15 23:22:36.590  WARN 47784 --- [           main] aWebConfiguration$JpaWebMvcConfiguration :  2020-07-15 23:22:36.849  INFO 47784 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 2 endpoint(s) beneath base path '/actuator' 2020-07-15 23:22:37.094  INFO 47784 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: Ant [pattern='/api/v1/login/*'], [] 2020-07-15 23:22:37.094  INFO 47784 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: Ant [pattern='/api/v1/version/ping'], [] 2020-07-15 23:22:37.094  INFO 47784 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: Ant [pattern='/v2/api-docs'], [] 2020-07-15 23:22:37.094  INFO 47784 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: Ant [pattern='/configuration/ui'], [] 2020-07-15 23:22:37.094  INFO 47784 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: Ant [pattern='/swagger-resources'], [] 2020-07-15 23:22:37.095  INFO 47784 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: Ant [pattern='/configuration/security'], [] 2020-07-15 23:22:37.151  INFO 47784 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@43045f9f, org.springframework.security.web.context.SecurityContextPersistenceFilter@22a736d7, org.springframework.security.web.header.HeaderWriterFilter@508a65bf, org.springframework.security.web.csrf.CsrfFilter@25290bca, org.keycloak.adapters.springsecurity.filter.KeycloakPreAuthActionsFilter@7a560583, org.springframework.security.web.authentication.logout.LogoutFilter@66273da0, org.keycloak.adapters.springsecurity.filter.KeycloakAuthenticationProcessingFilter@37052337, org.keycloak.adapters.springsecurity.filter.KeycloakAuthenticatedActionsFilter@4d722ac9, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@7f353d99, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@38d17d80, org.keycloak.adapters.springsecurity.filter.KeycloakSecurityContextRequestFilter@53f0a4cb, org.springframework.security.web.session.SessionManagementFilter@1e58512c, org.springframework.security.web.access.ExceptionTranslationFilter@4ac86d6a, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@26dc9bd5] 2020-07-15 23:22:37.179  INFO 47784 --- [           main] pertySourcedRequestMappingHandlerMapping : Mapped URL path [/v2/api-docs] onto method [public org.springframework.http.ResponseEntity<springfox.documentation.spring.web.json.Json> springfox.documentation.swagger2.web.Swagger2Controller.getDocumentation(java.lang.String,javax.servlet.http.HttpServletRequest)] 2020-07-15 23:22:37.441  INFO 47784 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor' 2020-07-15 23:22:37.864  INFO 47784 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed 2020-07-15 23:22:37.903  INFO 47784 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s) 2020-07-15 23:22:38.041  INFO 47784 --- [           main] s.d.s.w.s.ApiListingReferenceScanner     : Scanning for api listing references 2020-07-15 23:22:38.249  INFO 47784 --- [           main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: createUsingPOST_1 2020-07-15 23:22:38.255  INFO 47784 --- [           main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: deleteByIdUsingDELETE_1 2020-07-15 23:22:38.259  INFO 47784 --- [           main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: findAllUsingGET_1 2020-07-15 23:22:38.271  INFO 47784 --- [           main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: findByIdUsingGET_1 2020-07-15 23:22:38.288  INFO 47784 --- [           main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: searchUsingGET_1 2020-07-15 23:22:38.293  INFO 47784 --- [           main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: updateUsingPUT_1 2020-07-15 23:22:38.304  INFO 47784 --- [           main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: createUsingPOST_2 2020-07-15 23:22:38.310  INFO 47784 --- [           main] .d.s.w.r.o.CachingOperationNameGenerator : Generating unique operation named: deleteByIdUsingDELETE_2 2020-07-15 23:22:38.654  INFO 47784 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8081 (http) with context path '' 2020-07-15 23:22:38.656  INFO 47784 --- [           main] i.i.c.CaseMarketplaceApplication         : Started CaseMarketplaceApplication in 24.351 seconds (JVM running for 24.886) 

Currently i am using log4j which is configured via log4j2.xml like below is able to remove any useless information from startup log, but i don’t know why for springfox.documentation its not working.

<?xml version="1.0" encoding="UTF-8"?> <configuration strict="true" status="OFF" Log4jContextSelector="org.apache.logging.log4j.core.async.AsyncLoggerContextSelector">     <appenders>                    <Console name="console" target="SYSTEM_OUT">             <PatternLayout pattern="%highlight{%d{yyyyMMdd:HHmmssSSS}|%-20.20thread|%5p|%-25.25logger{25}| %m%throwable%n}"/>         </Console>         <Console name="consoleStartup" target="SYSTEM_OUT">             <PatternLayout pattern="%highlight{%d{yyyyMMdd:HHmmssSSS}|%-20.20thread|%5p| %m%throwable%n}"/>         </Console>              </appenders>     <loggers>                 <asyncLogger name="id.indexalaw.casemarketplace" level="INFO" additivity="false" includeLocation="true">             <appender-ref ref="systemAppender"/>                 </asyncLogger>         <asyncLogger name="access" level="debug" additivity="false">             <appender-ref ref="accessAppender"/>                 </asyncLogger>                  <!-- reqeust custom logger -->         <logger name="org.springframework.web.filter.CommonsRequestLoggingFilter" level="DEBUG" additivity="false">             <appender-ref ref="accessAppender"/>           </logger>                  <!-- log remover and editor-->         <logger name="org.springframework.context.support.PostProcessorRegistrationDelegate" level="OFF" additivity="false"></logger>         <logger name="springfox.documentation.spring.web.PropertySourcedRequestMappingHandlerMapping" level="OFF" additivity="false"></logger>         <logger name="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor" level="OFF" additivity="false"></logger>         <logger name="springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper" level="OFF" additivity="false"></logger>         <logger name="springfox.documentation.spring.web.readers.operation.CachingOperationNameGeneratorr" level="OFF" additivity="false"></logger>          <category name="springfox.documentation">             <priority value="off"/>         </category>         <category name="org.springframework.scheduling.concurrent">             <priority value="off"/>         </category>          <root additivity="false" level="info" includeLocation="true">             <appender-ref ref="console"/>                     <appender-ref ref="systemAppender"/>                       </root>             </loggers>         </configuration> 

Any help will be appreciated

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.