Skip to content

Commit

Permalink
站点统计优化
Browse files Browse the repository at this point in the history
  • Loading branch information
郑杰 committed Dec 26, 2018
1 parent d140f35 commit d787ed3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
18 changes: 18 additions & 0 deletions src/main/java/me/zhengjie/monitor/config/VisitsInitialization.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package me.zhengjie.monitor.config;

import lombok.extern.slf4j.Slf4j;
import me.zhengjie.monitor.service.VisitsService;
import org.springframework.context.annotation.Configuration;

/**
* 初始化站点统计
*/
@Slf4j
@Configuration
public class VisitsInitialization {

public VisitsInitialization(VisitsService visitsService){
log.info("--------------- 初始化站点统计,如果存在今日统计则跳过 ---------------");
visitsService.save();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ public void save() {

@Override
public void count(HttpServletRequest request) {

// 部署到线上后,可将save()删除
save();
LocalDate localDate = LocalDate.now();
Visits visits = visitsRepository.findByDate(localDate.toString());
visits.setPvCounts(visits.getPvCounts()+1);
Expand Down
16 changes: 1 addition & 15 deletions src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<contextName>elune</contextName>
<property name="log.path" value="log" />
<contextName>elAdmin</contextName>

<!--输出到控制台-->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
Expand All @@ -14,22 +13,9 @@
<filter class="me.zhengjie.monitor.config.LogFilter"></filter>
</appender>

<!--输出到文件-->
<!--<appender name="file" class="ch.qos.logback.system.rolling.RollingFileAppender">-->
<!--<rollingPolicy class="ch.qos.logback.system.rolling.TimeBasedRollingPolicy">-->
<!--<fileNamePattern>${log.path}/logback.%d{yyyy-MM-dd}.log</fileNamePattern>-->
<!--</rollingPolicy>-->
<!--<encoder>-->
<!--<pattern>%d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n</pattern>-->
<!--</encoder>-->
<!--</appender>-->



<!--普通日志输出到控制台-->
<root level="info">
<appender-ref ref="console" />
<!--<appender-ref ref="file" />-->
</root>

<!-- logback为java中的包 -->
Expand Down

0 comments on commit d787ed3

Please sign in to comment.