You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Remko Popma (JIRA)" <ji...@apache.org> on 2014/08/06 13:31:13 UTC

[jira] [Resolved] (LOG4J2-540) Add an ability to load an alternative Log4j config file

     [ https://issues.apache.org/jira/browse/LOG4J2-540?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Remko Popma resolved LOG4J2-540.
--------------------------------

    Resolution: Implemented

Resolving this issue as "Implemented" since log4j2 already has the ability to load from a log4j2-test.xml, and if that does not exist, then load from log4j2.xml. (See [Automatic Configuration|http://logging.apache.org/log4j/2.x/manual/configuration.html#AutomaticConfiguration].)

Please feel free to re-open if this is still a problem or close if you are satisfied with this solution.

> Add an ability to load an alternative Log4j config file
> -------------------------------------------------------
>
>                 Key: LOG4J2-540
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-540
>             Project: Log4j 2
>          Issue Type: Wish
>    Affects Versions: 2.0-beta9
>            Reporter: Dushyant Pandya
>              Labels: configuration, configuration-addition, features, location
>
> *Current Situation:*
> In case of web applications, the Log4J2 loads a config file specified by the servlet context init param *log4jConfiguration*. If the location is *classpath:* location then that config file would be searched somewhere in the classpath. Usually, to keep the web application WAR self sufficient the config file is bundled in *WEB-INF/classes* dir of the WAR itself.
> *Problem:*
> The config file usually has machine/env dependent information like the log file location, the log levels etc. These values and sometimes the whole file may be different depending upon where the app is running (e.g., developer machine, qa or production etc). In many organizations, the deployment scripts/tools specify these files per env or alter the values per env during deployment time. This is very difficult to do if the config file is bundled inside the WAR. An alternative is to NOT bundle the config file inside WAR and put it in some system classpath location but that solution makes the WAR not self contained. 
> *Wish:*
> Wish there was an ability to specify a preferred log4j config file that will be used if it exists and a fallback config file location if the preferred config file doesn't exist. 
> For example, with the following in _web.xml_
> {code}
>    <context-param>
>       <param-name>log4jConfiguration</param-name>
>       <param-value>file:///file1.xml,classpath:file2.xml</param-value>
>    </context-param>
> {code}
> The _file1.xml_ can be somewhere on file system or external classpath location and could be env specific. The _file2.xml_ can be the default file bundled in the WAR itself. If _file1.xml_ exists then it will take the precedence, if it doesn't exist then _file2.xml_ will be used. This idea is similar to the way _Spring Framework_ allows specifying multiple values to the *location* attribute when specifying [property placeholder|http://docs.spring.io/spring/docs/4.0.1.RELEASE/spring-framework-reference/htmlsingle/#beans-factory-placeholderconfigurer].



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org