[logback-user] Avoid error on undefined JNDI variable

Brian Xinger bryx666 at yahoo.com
Wed Jul 1 04:11:03 CEST 2020


Hi, sorry if this is a noob question. I really searched but could not find a way.
I have a war-packaged application. I have configured logback to get an variable from JNDI with "insertFromJNDI" and placed the definition of that variable in a tomcat context XML. All of this works just fine when I deploy the application the way I want.
Now, when running the application for tests or development, I would like to be able to have a default value for this variable. I can work with the :- operator when I define the log file name, but the problem I am having is that the missing JNDI parameter is causing an error and an abort of the application startup. The error shows:
java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.classic.joran.action.InsertFromJNDIAction - [java:comp/env/instanceName] has null or empty value
This happens with Eclipse and a Tomcat server managed by the IDE and on a Spring Boot embedded tomcat as well. I imagine many might reply suggesting ways to define the JNDI parameter in those situations, something I am open too and would appreciate, but deep down my question is: should the missing parameter really be an error? shouldn't it just issue a warning at most and not throw the exception, leaving the variable undefined just like any other env variable to be used with ":-"? Is that something that can be configured by any chance?
Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20200701/280b2543/attachment.html>


More information about the logback-user mailing list