package fr.insee.pogues.config;

import org.apache.logging.log4j.web.Log4jServletContextListener;
import org.apache.logging.log4j.web.Log4jWebSupport;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class Log4j2ServletContextListener implements ServletContextListener {

    private String log4j2ConfigFile;

    private Log4jServletContextListener listener;

    public Log4j2ServletContextListener() {
        this.listener = new Log4jServletContextListener();
        this.log4j2ConfigFile = String.format("%s/log4j2.xml", System.getProperty("fr.insee.pogues.env"));
    }

    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        servletContextEvent.getServletContext().setInitParameter(
                Log4jWebSupport.LOG4J_CONFIG_LOCATION,
                log4j2ConfigFile);
        listener.contextInitialized(servletContextEvent);
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) { }
}

@@ -504,16 +504,140 @@
 ener();%0A
+        String env = System.getProperty(%22fr.insee.pogues.env%22);%0A        if(null == env) %7B%0A            env = %22dv%22;%0A        %7D%0A
         
@@ -695,49 +695,11 @@
 l%22, 
-System.getProperty(%22fr.insee.pogues.
 env
-%22)
 );%0A 

Add default environment to logger: dv