Browse Source
# Conflicts: # src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java # web_src/src/components/control.vuepull/375/head
648540858
3 years ago
39 changed files with 569 additions and 247 deletions
@ -0,0 +1,64 @@ |
|||||
|
package com.genersoft.iot.vmp.conf.druid; |
||||
|
|
||||
|
import com.alibaba.druid.support.http.StatViewServlet; |
||||
|
import com.alibaba.druid.support.http.WebStatFilter; |
||||
|
import org.springframework.beans.factory.annotation.Value; |
||||
|
import org.springframework.boot.web.servlet.FilterRegistrationBean; |
||||
|
import org.springframework.boot.web.servlet.ServletRegistrationBean; |
||||
|
import org.springframework.context.annotation.Bean; |
||||
|
|
||||
|
import javax.servlet.Filter; |
||||
|
import javax.servlet.Servlet; |
||||
|
|
||||
|
/** |
||||
|
* druid监控配置 |
||||
|
* @author |
||||
|
*/ |
||||
|
public class DruidConfiguration { |
||||
|
|
||||
|
@Value("${rj-druid-manage.allow:127.0.0.1}") |
||||
|
private String allow; |
||||
|
|
||||
|
@Value("${rj-druid-manage.deny:}") |
||||
|
private String deny; |
||||
|
|
||||
|
@Value("${rj-druid-manage.loginUsername:admin}") |
||||
|
private String loginUsername; |
||||
|
|
||||
|
@Value("${rj-druid-manage.loginPassword:admin}") |
||||
|
private String loginPassword; |
||||
|
|
||||
|
@Value("${rj-druid-manage.resetEnable:false}") |
||||
|
private String resetEnable; |
||||
|
|
||||
|
/** |
||||
|
* druid监控页面开启 |
||||
|
*/ |
||||
|
@Bean |
||||
|
public ServletRegistrationBean druidServlet() { |
||||
|
ServletRegistrationBean<Servlet> servletRegistrationBean = new ServletRegistrationBean<>(new StatViewServlet(), "/druid/*"); |
||||
|
// IP白名单
|
||||
|
servletRegistrationBean.addInitParameter("allow", allow); |
||||
|
// IP黑名单(共同存在时,deny优先于allow)
|
||||
|
servletRegistrationBean.addInitParameter("deny", deny); |
||||
|
//控制台管理用户
|
||||
|
servletRegistrationBean.addInitParameter("loginUsername", loginUsername); |
||||
|
servletRegistrationBean.addInitParameter("loginPassword", loginPassword); |
||||
|
//是否能够重置数据 禁用HTML页面上的“Reset All”功能
|
||||
|
servletRegistrationBean.addInitParameter("resetEnable", resetEnable); |
||||
|
return servletRegistrationBean; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* druid url监控配置 |
||||
|
*/ |
||||
|
@Bean |
||||
|
public FilterRegistrationBean filterRegistrationBean() { |
||||
|
FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<>(new WebStatFilter()); |
||||
|
filterRegistrationBean.addUrlPatterns("/*"); |
||||
|
filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"); |
||||
|
return filterRegistrationBean; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
package com.genersoft.iot.vmp.conf.druid; |
||||
|
|
||||
|
import org.springframework.boot.web.servlet.ServletComponentScan; |
||||
|
import org.springframework.context.annotation.Import; |
||||
|
|
||||
|
import java.lang.annotation.*; |
||||
|
|
||||
|
/** |
||||
|
* druid监控支持注解 |
||||
|
* |
||||
|
* @author |
||||
|
* {@link DruidConfiguration} druid监控页面安全配置支持 |
||||
|
* {@link ServletComponentScan} druid监控页面需要扫描servlet |
||||
|
*/ |
||||
|
@Target(ElementType.TYPE) |
||||
|
@Retention(RetentionPolicy.RUNTIME) |
||||
|
@Documented |
||||
|
@Inherited |
||||
|
@Import({ |
||||
|
DruidConfiguration.class, |
||||
|
}) |
||||
|
@ServletComponentScan |
||||
|
public @interface EnableDruidSupport { |
||||
|
} |
@ -1,3 +1,3 @@ |
|||||
spring: |
spring: |
||||
profiles: |
profiles: |
||||
active: local |
active: dev |
||||
|
@ -0,0 +1,97 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<configuration debug="false"> |
||||
|
<!--定义日志文件的存储地址 --> |
||||
|
<springProperty scop="context" name="spring.application.name" source="spring.application.name" defaultValue=""/> |
||||
|
<property name="LOG_HOME" value="logs/${spring.application.name}" /> |
||||
|
|
||||
|
<!--<property name="COLOR_PATTERN" value="%black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta( %replace(%caller{1}){'\t|Caller.{1}0|\r\n', ''})- %gray(%msg%xEx%n)" />--> |
||||
|
<!-- 控制台输出 --> |
||||
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> |
||||
|
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> |
||||
|
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 --> |
||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern> |
||||
|
</encoder> |
||||
|
</appender> |
||||
|
|
||||
|
<!-- 按照每天生成日志文件 DEBUG以上级别的日志,仅用于测试环境,正式环境为info级别以上的日志--> |
||||
|
<appender name="RollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
|
|
||||
|
<!-- 文件路径 --> |
||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> |
||||
|
<!--历史日志文件输出的文件名 --> |
||||
|
<FileNamePattern>${LOG_HOME}/wvp-%d{yyyy-MM-dd}.%i.log</FileNamePattern> |
||||
|
<!--日志文件保留天数 --> |
||||
|
<MaxHistory>30</MaxHistory> |
||||
|
<maxFileSize>20MB</maxFileSize> |
||||
|
</rollingPolicy> |
||||
|
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> |
||||
|
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 --> |
||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern> |
||||
|
</encoder> |
||||
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> |
||||
|
<!--与ThresholdFilter的区别,允许onmatch--> |
||||
|
<!--设置日志级别 接收info级别的日志--> |
||||
|
<level>DEBUG</level> |
||||
|
</filter> |
||||
|
</appender> |
||||
|
|
||||
|
<!-- 生成 error格式日志开始 --> |
||||
|
<appender name="RollingFileError" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
|
|
||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> |
||||
|
<!--历史日志文件输出的文件名 --> |
||||
|
<FileNamePattern>${LOG_HOME}/error-%d{yyyy-MM-dd}.%i.log</FileNamePattern> |
||||
|
<!--日志文件保留天数 --> |
||||
|
<MaxHistory>30</MaxHistory> |
||||
|
<maxFileSize>20MB</maxFileSize> |
||||
|
</rollingPolicy> |
||||
|
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> |
||||
|
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 --> |
||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern> |
||||
|
</encoder> |
||||
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> |
||||
|
<!--设置日志级别,过滤掉info日志,只输入error日志--> |
||||
|
<level>WARN</level> |
||||
|
<!-- <onMatch>ACCEPT</onMatch> <!– 用过滤器,只接受ERROR级别的日志信息,其余全部过滤掉 –>--> |
||||
|
<!-- <onMismatch>DENY</onMismatch>--> |
||||
|
</filter> |
||||
|
</appender> |
||||
|
|
||||
|
<!-- 生成 druid日志追加 --> |
||||
|
<appender name="druidSqlRollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> |
||||
|
<!--历史日志文件输出的文件名 --> |
||||
|
<FileNamePattern>${LOG_HOME}/druid-%d{yyyy-MM-dd}.%i.log</FileNamePattern> |
||||
|
<!--日志文件保留天数 --> |
||||
|
<MaxHistory>30</MaxHistory> |
||||
|
<maxFileSize>50MB</maxFileSize> |
||||
|
</rollingPolicy> |
||||
|
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> |
||||
|
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 --> |
||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern> |
||||
|
</encoder> |
||||
|
</appender> |
||||
|
|
||||
|
|
||||
|
<!-- 日志输出级别 --> |
||||
|
<root level="INFO"> |
||||
|
<appender-ref ref="STDOUT" /> |
||||
|
<appender-ref ref="RollingFile" /> |
||||
|
<appender-ref ref="RollingFileError" /> |
||||
|
</root> |
||||
|
|
||||
|
<logger name="com.genersoft.iot.vmp.storager.dao" level="INFO"> |
||||
|
<appender-ref ref="STDOUT"/> |
||||
|
</logger> |
||||
|
<logger name="com.genersoft.iot.vmp.gb28181" level="DEBUG"> |
||||
|
<appender-ref ref="STDOUT"/> |
||||
|
</logger> |
||||
|
|
||||
|
<!--记录druid-sql的记录--> |
||||
|
<logger name="druid.sql.Statement" level="debug" additivity="true"> |
||||
|
<!--AppenderRef ref="Console"/--> |
||||
|
<!-- <appender-ref ref="RollingFile"/>--> |
||||
|
<appender-ref ref="RollingFileError"/> |
||||
|
<appender-ref ref="druidSqlRollingFile"/> |
||||
|
</logger> |
||||
|
</configuration> |
Loading…
Reference in new issue