Commit 95e5faeb authored by Piotr Gawron's avatar Piotr Gawron
Browse files

log4j2.configuration wasn't loading

parent 64ef02af
package lcsb.mapviewer.web.config;
import java.net.URL;
import java.util.EnumSet;
import javax.servlet.*;
import org.apache.logging.log4j.core.LoggerContext;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
import lcsb.mapviewer.annotation.SpringAnnotationConfig;
import lcsb.mapviewer.api.SpringRestApiConfig;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.persist.SpringPersistConfig;
import lcsb.mapviewer.services.SpringServiceConfig;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
import javax.servlet.*;
import java.util.EnumSet;
public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
......@@ -45,6 +49,21 @@ public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServlet
assert container.setInitParameter("javax.faces.DEFAULT_SUFFIX", ".xhtml");
assert container.setInitParameter("javax.faces.FACELETS_SKIP_COMMENTS", "true");
// FIXME: Why does this not work?
// assert container.setInitParameter("log4jConfigLocation",
// "/WEB-INF/resources/log4j2.properties");
// Workaround for above
String file = "/WEB-INF/resources/log4j2.properties";
try {
URL configStream = container.getResource(file);
LoggerContext context = (org.apache.logging.log4j.core.LoggerContext) org.apache.logging.log4j.LogManager
.getContext(false);
context.setConfigLocation(configStream.toURI());
} catch (Exception e) {
logger.error("Problem with loading log4j configuration: " + file);
}
SessionCookieConfig cookieConfig = container.getSessionCookieConfig();
cookieConfig.setName(Configuration.AUTH_TOKEN);
cookieConfig.setHttpOnly(false);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment