多环境不同环境下使用不同配置文件
This commit is contained in:
parent
0e454011ef
commit
875ccfdbbd
|
@ -41,3 +41,10 @@ webssh 和 评测的pod分别放到不同的namespace下
|
|||
1. 评测:environment-tpi
|
||||
2. webssh: webssh-environment-tpi
|
||||
3. webssh+评测: evassh-environment-tpi
|
||||
|
||||
**多profile配置**
|
||||
在tomcat/bin目录下的setenv.sh文件中设置了启动时使用的profile,
|
||||
如: `-Dspring.profiles.active=test`
|
||||
|
||||
**日志**
|
||||
正式版按天生成,测试版记入catalina.out文件中
|
|
@ -8,7 +8,7 @@ import org.springframework.context.annotation.PropertySource;
|
|||
* Created by guange on 18/02/2017.
|
||||
*/
|
||||
@Configuration("AppConfig")
|
||||
@PropertySource("classpath:config.properties")
|
||||
@PropertySource("classpath:config_${spring.profiles.active}.properties")
|
||||
public class AppConfig {
|
||||
|
||||
@Value("${educoderURL}")
|
||||
|
|
|
@ -30,7 +30,8 @@ public final class RedisPool {
|
|||
static {
|
||||
try {
|
||||
Properties prop = new Properties();
|
||||
prop.load(RedisPool.class.getClassLoader().getResourceAsStream("config.properties"));
|
||||
String active = System.getProperty("spring.profiles.active");
|
||||
prop.load(RedisPool.class.getClassLoader().getResourceAsStream("config_" + active + ".properties"));
|
||||
|
||||
String ADDR = prop.getProperty("redisAddress");
|
||||
int PORT = Integer.parseInt(prop.getProperty("redisPort"));
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<pattern>%d{MM-dd HH:mm:ss} [%thread] %-5level -- %msg%n</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>DEBUG</level>
|
||||
<level>INFO</level>
|
||||
</filter>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log_path}bridge.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
|
@ -23,7 +23,7 @@
|
|||
<looger name="com.spotify.docker.client" level="ERROR"/>
|
||||
|
||||
<root>
|
||||
<level value="DEBUG"/>
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="bridge"/>
|
||||
</root>
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<!-- 打印在标准控制台 -->
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<!--格式化输出:%d:时间,%thread:线程名,%-5level:级别从左显示5个字符宽度,
|
||||
%logger{50}:输出日志的类, 50代表包名加类名的总长度限制, %M 方法名 %L 行号 %msg:日志消息,%n是换行符-->
|
||||
<pattern>%d{MM-dd HH:mm:ss} [%thread] %-5level -- %msg%n</pattern>
|
||||
</encoder>
|
||||
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>DEBUG</level>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 屏蔽框架输出 -->
|
||||
<logger name="org.slf4j" level="ERROR"/>
|
||||
<logger name="org.springframework" level="ERROR"/>
|
||||
<logger name="io.swagger" level="ERROR"/>
|
||||
<logger name="ch.qos.logback" level="OFF"/>
|
||||
<logger name="springfox.documentation" level="ERROR"/>
|
||||
<looger name="com.spotify.docker.client" level="ERROR"/>
|
||||
|
||||
<root>
|
||||
<level value="DEBUG"/>
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
|
||||
</configuration>
|
|
@ -21,7 +21,7 @@
|
|||
<!-- logback -->
|
||||
<context-param>
|
||||
<param-name>logbackConfigLocation</param-name>
|
||||
<param-value>classpath:logback.xml</param-value>
|
||||
<param-value>classpath:logback_${spring.profiles.active}.xml</param-value>
|
||||
</context-param>
|
||||
|
||||
<listener>
|
||||
|
|
Loading…
Reference in New Issue