java - Switching between log4j configs -
i've implemented spring profiles, in web.xml
added default profile:
<context-param> <param-name>spring.profiles.default</param-name> <param-value>prod</param-value> </context-param>
and in applicationcontext.xml
can switch between config file use:
<beans profile="dev"> <context:property-placeholder location="classpath*:meta-inf/spring/dev.properties"/> </beans> <beans profile="prod"> <context:property-placeholder location="classpath*:meta-inf/spring/prod.properties"/> </beans>
and i've made mvn jetty:run
use dev profile:
<plugin> <groupid>org.eclipse.jetty</groupid> <artifactid>jetty-maven-plugin</artifactid> <version>9.2.10.v20150310</version> <configuration> <webappconfig> <contextpath>/${project.artifactid}</contextpath> <sessionhandler implementation="org.eclipse.jetty.server.session.sessionhandler"> <sessionmanager implementation="org.eclipse.jetty.server.session.hashsessionmanager"> <!-- disable url sessions using jsessionid --> <sessionidpathparametername>none</sessionidpathparametername> </sessionmanager> </sessionhandler> </webappconfig> <httpconnector> <port>9091</port> </httpconnector> <systemproperties> <systemproperty> <name>spring.profiles.active</name> <value>dev</value> </systemproperty> </systemproperties> </configuration> </plugin>
how switch between different log4j configurations?
i'm using sl4j log4j:
<dependency> <groupid>log4j</groupid> <artifactid>log4j</artifactid> <version>1.2.17</version> </dependency> <dependency> <groupid>org.slf4j</groupid> <artifactid>slf4j-api</artifactid> <version>${slf4j.version}</version> </dependency> <dependency> <groupid>org.slf4j</groupid> <artifactid>jcl-over-slf4j</artifactid> <version>${slf4j.version}</version> </dependency> <dependency> <groupid>org.slf4j</groupid> <artifactid>slf4j-log4j12</artifactid> <version>${slf4j.version}</version> </dependency>
in dev log stdout
, in production log both stdout
, queue
(queue being rabbitmq)?
obviously spring not yet loaded when log4j starts (no pun intended), seems spring profiles out.
how can switch between different log4j configurations - log4j-dev.properties
, log4j-prod.properties
Comments
Post a Comment