今天在weblogic上部署一个使用logback的应用时,报错如下:
java.lang.IllegalArgumentException: Invalid 'logbackConfigLocation' parameter: /opt/app/Oracle/Middleware/user_projects/domains/base_domain/servers/Server7005/tmp/_WL_user/acc_service_ca/bk1axn/war/WEB-INF/lib/_wl_cls_gen.jar!/logback.xml
网上搜索了一翻,大致原因是weblogic已经自带了slf4j的模块,与应用中的logback冲突,按照官网 https://community.oracle.com/thread/3525130?start=0&tstart=0 的做法,在WEB-INF下放一个名为weblogic.xml的文件,参考以下内容:
1 <?xml version="1.0" encoding="UTF-8"?> 2 3 <weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90"> 4 <session-descriptor> 5 <cookie-path>/</cookie-path> 6 </session-descriptor> 7 8 <jsp-descriptor> 9 <keepgenerated>true</keepgenerated> 10 <page-check-seconds>60</page-check-seconds> 11 <precompile>true</precompile> 12 <precompile-continue>true</precompile-continue> 13 </jsp-descriptor> 14 15 <container-descriptor> 16 <optimistic-serialization>true</optimistic-serialization> 17 <prefer-web-inf-classes>false</prefer-web-inf-classes> 18 <show-archived-real-path-enabled>true</show-archived-real-path-enabled> 19 <prefer-application-packages> 20 <package-name>org.slf4j</package-name> 21 </prefer-application-packages> 22 23 </container-descriptor> 24 </weblogic-web-app>
关键是17-21这几行,在weblogic 10.3.3版本上验证通过
时间: 2024-09-29 03:20:01