Logback can't find logback.xml even though it exists (on the classpath)

The location within the WAR file is correct, WEB-INF/classes.

The logback configuration documentation talks about where the logback.xml file can be located within a war, but it doesn't mention anything about an EAR.

Could you please try the information at this link? I am wondering if it needs to be packed into the EAR in a specific way.

  1. Glassfish 3 + ear + logback.xml

(edit: second link removed, didn't work)


Logback invokes very similar code to the code in your example, i.e.

getClassLoader().getResourceAsStream("logback.xml");

If logback cannot find logback.xml, then it must be that the resource is not visible to the class loader that loaded the logback class. This class loader is most probably different than the class loader that loaded your test code which can find logback.xml.