add:日志
This commit is contained in:
@@ -463,12 +463,12 @@
|
|||||||
<artifactId>lucene-queryparser</artifactId>
|
<artifactId>lucene-queryparser</artifactId>
|
||||||
<version>${lucene.version}</version>
|
<version>${lucene.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>com.yomahub</groupId>
|
<!-- <groupId>com.yomahub</groupId>-->
|
||||||
<artifactId>tlog-core</artifactId>
|
<!-- <artifactId>tlog-core</artifactId>-->
|
||||||
<version>1.5.0</version>
|
<!-- <version>1.5.0</version>-->
|
||||||
<scope>compile</scope>
|
<!-- <scope>compile</scope>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@@ -51,8 +51,6 @@ import java.util.Map;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class LogAspect {
|
public class LogAspect {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 配置环绕通知,使用在方法logPointcut()上注册的切入点
|
* 配置环绕通知,使用在方法logPointcut()上注册的切入点
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -26,9 +26,6 @@ public class AsyncLuceneAppender extends AspectLogbackAsyncAppender {
|
|||||||
}
|
}
|
||||||
MDC.clear();
|
MDC.clear();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
public void appendSync(ILoggingEvent event){
|
|
||||||
super.append(event);
|
super.append(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class LuceneAppender extends AppenderBase<ILoggingEvent> {
|
|||||||
if (!map.isEmpty() && StringUtils.isNotEmpty(map.get("traceId"))){
|
if (!map.isEmpty() && StringUtils.isNotEmpty(map.get("traceId"))){
|
||||||
doc.add(new StringField("traceId",map.get("traceId"), Field.Store.YES));
|
doc.add(new StringField("traceId",map.get("traceId"), Field.Store.YES));
|
||||||
}else {
|
}else {
|
||||||
doc.add(new StringField("traceId", IdUtil.getStringId(), Field.Store.YES));
|
doc.add(new StringField("traceId", " ", Field.Store.YES));
|
||||||
}
|
}
|
||||||
|
|
||||||
doc.add(new TextField(LogMessageConstant.FIELD_MESSAGE, event.getFormattedMessage(), Field.Store.YES));
|
doc.add(new TextField(LogMessageConstant.FIELD_MESSAGE, event.getFormattedMessage(), Field.Store.YES));
|
||||||
|
|||||||
@@ -1,17 +1,24 @@
|
|||||||
package org.nl.config.mybatis;
|
package org.nl.config.mybatis;
|
||||||
|
|
||||||
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
import com.baomidou.mybatisplus.annotation.DbType;
|
import com.baomidou.mybatisplus.annotation.DbType;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
@Configuration
|
@Configuration
|
||||||
public class MybatisPlusConfig {
|
public class MybatisPlusConfig {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DataSource dataSource;
|
||||||
/**
|
/**
|
||||||
* 新的分页插件,一缓和二缓遵循mybatis的规则,需要设置 MybatisConfiguration#useDeprecatedExecutor = false 避免缓存出现问题(该属性会在旧插件移除后一同移除)
|
* 新的分页插件,一缓和二缓遵循mybatis的规则,需要设置 MybatisConfiguration#useDeprecatedExecutor = false 避免缓存出现问题(该属性会在旧插件移除后一同移除)
|
||||||
添加自增插件
|
添加自增插件
|
||||||
@@ -28,4 +35,10 @@ public class MybatisPlusConfig {
|
|||||||
return interceptor;
|
return interceptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void datainnit() {
|
||||||
|
String url = ((DruidDataSource) dataSource).getUrl();
|
||||||
|
System.out.println("项目数据库地址:" + url);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
//@Component
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Order(100)
|
@Order(100)
|
||||||
public class JobRunner implements ApplicationRunner {
|
public class JobRunner implements ApplicationRunner {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ spring:
|
|||||||
# 超时时间(以秒数为单位)
|
# 超时时间(以秒数为单位)
|
||||||
remove-abandoned-timeout: 180
|
remove-abandoned-timeout: 180
|
||||||
# 获取连接超时时间
|
# 获取连接超时时间
|
||||||
max-wait: 3000
|
max-wait: 9000
|
||||||
# 连接有效性检测时间
|
# 连接有效性检测时间
|
||||||
time-between-eviction-runs-millis: 60000
|
time-between-eviction-runs-millis: 60000
|
||||||
# 连接在池中最小生存的时间
|
# 连接在池中最小生存的时间
|
||||||
@@ -156,5 +156,5 @@ sa-token:
|
|||||||
timeout: 10s
|
timeout: 10s
|
||||||
lucene:
|
lucene:
|
||||||
index:
|
index:
|
||||||
path: D:\lms\lucene\index
|
path: E:\lms\lucene\index
|
||||||
|
|
||||||
|
|||||||
@@ -112,6 +112,6 @@ mybatis-plus:
|
|||||||
id-type: INPUT
|
id-type: INPUT
|
||||||
lucene:
|
lucene:
|
||||||
index:
|
index:
|
||||||
path: D:\lms\lucene\index
|
path: E:\lms\lucene\index
|
||||||
tlog:
|
tlog:
|
||||||
enable-invoke-time-print: true
|
enable-invoke-time-print: true
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ service.interceptors.response.use(
|
|||||||
return response.data
|
return response.data
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
|
console.log(error)
|
||||||
// 兼容blob下载出错json提示
|
// 兼容blob下载出错json提示
|
||||||
if (error.response.data instanceof Blob && error.response.data.type.toLowerCase().indexOf('json') !== -1) {
|
if (error.response.data instanceof Blob && error.response.data.type.toLowerCase().indexOf('json') !== -1) {
|
||||||
const reader = new FileReader()
|
const reader = new FileReader()
|
||||||
|
|||||||
@@ -1,139 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="app-container">
|
|
||||||
<div class="head-container">
|
|
||||||
<Search />
|
|
||||||
<crudOperation>
|
|
||||||
<el-button
|
|
||||||
slot="left"
|
|
||||||
class="filter-item"
|
|
||||||
type="danger"
|
|
||||||
icon="el-icon-delete"
|
|
||||||
size="mini"
|
|
||||||
:loading="crud.delAllLoading"
|
|
||||||
@click="confirmDelAll()"
|
|
||||||
>
|
|
||||||
清空
|
|
||||||
</el-button>
|
|
||||||
</crudOperation>
|
|
||||||
</div>
|
|
||||||
<!--表格渲染-->
|
|
||||||
<el-table ref="table" v-loading="crud.loading" :data="crud.data" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
|
|
||||||
<el-table-column type="expand">
|
|
||||||
<template slot-scope="props">
|
|
||||||
<el-form label-position="left" inline class="demo-table-expand">
|
|
||||||
<el-form-item label="请求方法">
|
|
||||||
<span>{{ props.row.method }}</span>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="请求参数">
|
|
||||||
<span>{{ props.row.params }}</span>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="username" label="用户名" />
|
|
||||||
<el-table-column prop="request_ip" label="IP" />
|
|
||||||
<el-table-column show-overflow-tooltip prop="address" label="IP来源" />
|
|
||||||
<el-table-column prop="description" label="描述" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="browser" label="浏览器" min-width="120" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="create_time" label="创建日期" min-width="100" show-overflow-tooltip>
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<span>{{ parseTime(scope.row.create_time) }}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="异常详情" width="100px">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<el-button size="mini" type="text" @click="info(scope.row.log_id)">查看详情</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
<el-dialog :visible.sync="dialog" title="异常详情" append-to-body top="30px" width="85%">
|
|
||||||
<pre v-highlightjs="errorInfo"><code class="java" /></pre>
|
|
||||||
</el-dialog>
|
|
||||||
<!--分页组件-->
|
|
||||||
<pagination />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { getErrDetail, delAllError } from '@/api/monitor/log'
|
|
||||||
import Search from './search'
|
|
||||||
import CRUD, { presenter } from '@crud/crud'
|
|
||||||
import crudOperation from '@crud/CRUD.operation'
|
|
||||||
import pagination from '@crud/Pagination'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'ErrorLog',
|
|
||||||
components: { Search, crudOperation, pagination },
|
|
||||||
cruds() {
|
|
||||||
return CRUD({ title: '异常日志', url: 'api/logs/error' })
|
|
||||||
},
|
|
||||||
mixins: [presenter()],
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
errorInfo: '', dialog: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.crud.optShow = {
|
|
||||||
add: false,
|
|
||||||
edit: false,
|
|
||||||
del: false,
|
|
||||||
download: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// 获取异常详情
|
|
||||||
info(log_id) {
|
|
||||||
this.dialog = true
|
|
||||||
getErrDetail(log_id).then(res => {
|
|
||||||
this.errorInfo = res.exception
|
|
||||||
})
|
|
||||||
},
|
|
||||||
confirmDelAll() {
|
|
||||||
this.$confirm(`确认清空所有异常日志吗?`, '提示', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
cancelButtonText: '取消',
|
|
||||||
type: 'warning'
|
|
||||||
}).then(() => {
|
|
||||||
this.crud.delAllLoading = true
|
|
||||||
delAllError().then(res => {
|
|
||||||
this.crud.delAllLoading = false
|
|
||||||
this.crud.dleChangePage(1)
|
|
||||||
this.crud.delSuccessNotify()
|
|
||||||
this.crud.toQuery()
|
|
||||||
}).catch(err => {
|
|
||||||
this.crud.delAllLoading = false
|
|
||||||
console.log(err.response.data.message)
|
|
||||||
})
|
|
||||||
}).catch(() => {
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.demo-table-expand {
|
|
||||||
font-size: 0;
|
|
||||||
}
|
|
||||||
.demo-table-expand label {
|
|
||||||
width: 70px;
|
|
||||||
color: #99a9bf;
|
|
||||||
}
|
|
||||||
.demo-table-expand .el-form-item {
|
|
||||||
margin-right: 0;
|
|
||||||
margin-bottom: 0;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.demo-table-expand .el-form-item__content {
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
/deep/ .el-dialog__body {
|
|
||||||
padding: 0 20px 10px 20px !important;
|
|
||||||
}
|
|
||||||
.java.hljs {
|
|
||||||
color: #444;
|
|
||||||
background: #ffffff !important;
|
|
||||||
height: 630px !important;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,118 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="app-container">
|
|
||||||
<div class="head-container">
|
|
||||||
<Search />
|
|
||||||
<crudOperation>
|
|
||||||
<el-button
|
|
||||||
slot="left"
|
|
||||||
class="filter-item"
|
|
||||||
type="danger"
|
|
||||||
icon="el-icon-delete"
|
|
||||||
size="mini"
|
|
||||||
:loading="crud.delAllLoading"
|
|
||||||
@click="confirmDelAll()"
|
|
||||||
>
|
|
||||||
清空
|
|
||||||
</el-button>
|
|
||||||
</crudOperation>
|
|
||||||
</div>
|
|
||||||
<!--表格渲染-->
|
|
||||||
<el-table ref="table" v-loading="crud.loading" :data="crud.data" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
|
|
||||||
<el-table-column type="expand">
|
|
||||||
<template slot-scope="props">
|
|
||||||
<el-form label-position="left" inline class="demo-table-expand">
|
|
||||||
<el-form-item label="请求方法">
|
|
||||||
<span>{{ props.row.method }}</span>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="请求参数">
|
|
||||||
<span>{{ props.row.params }}</span>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="username" label="用户名" />
|
|
||||||
<el-table-column prop="request_ip" label="IP" />
|
|
||||||
<el-table-column show-overflow-tooltip prop="address" label="IP来源" />
|
|
||||||
<el-table-column prop="description" label="描述" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="browser" label="浏览器" min-width="120" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="time" label="请求耗时" align="center">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<el-tag v-if="scope.row.time <= 300">{{ scope.row.time }}ms</el-tag>
|
|
||||||
<el-tag v-else-if="scope.row.time <= 1000" type="warning">{{ scope.row.time }}ms</el-tag>
|
|
||||||
<el-tag v-else type="danger">{{ scope.row.time }}ms</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="create_time" label="创建日期" width="180px">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<span>{{ parseTime(scope.row.create_time) }}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
<!--分页组件-->
|
|
||||||
<pagination />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import Search from './search'
|
|
||||||
import { delAllInfo } from '@/api/monitor/log'
|
|
||||||
import CRUD, { presenter } from '@crud/crud'
|
|
||||||
import crudOperation from '@crud/CRUD.operation'
|
|
||||||
import pagination from '@crud/Pagination'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'Log',
|
|
||||||
components: { Search, crudOperation, pagination },
|
|
||||||
cruds() {
|
|
||||||
return CRUD({ title: '日志', url: 'api/logs' })
|
|
||||||
},
|
|
||||||
mixins: [presenter()],
|
|
||||||
created() {
|
|
||||||
this.crud.optShow = {
|
|
||||||
add: false,
|
|
||||||
edit: false,
|
|
||||||
del: false,
|
|
||||||
download: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
confirmDelAll() {
|
|
||||||
this.$confirm(`确认清空所有操作日志吗?`, '提示', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
cancelButtonText: '取消',
|
|
||||||
type: 'warning'
|
|
||||||
}).then(() => {
|
|
||||||
this.crud.delAllLoading = true
|
|
||||||
delAllInfo().then(res => {
|
|
||||||
this.crud.delAllLoading = false
|
|
||||||
this.crud.dleChangePage(1)
|
|
||||||
this.crud.delSuccessNotify()
|
|
||||||
this.crud.toQuery()
|
|
||||||
}).catch(err => {
|
|
||||||
this.crud.delAllLoading = false
|
|
||||||
console.log(err.response.data.message)
|
|
||||||
})
|
|
||||||
}).catch(() => {
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.demo-table-expand {
|
|
||||||
font-size: 0;
|
|
||||||
}
|
|
||||||
.demo-table-expand label {
|
|
||||||
width: 70px;
|
|
||||||
color: #99a9bf;
|
|
||||||
}
|
|
||||||
.demo-table-expand .el-form-item {
|
|
||||||
margin-right: 0;
|
|
||||||
margin-bottom: 0;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.demo-table-expand .el-form-item__content {
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div v-if="crud.props.searchToggle">
|
|
||||||
<el-input
|
|
||||||
v-model="query.blurry"
|
|
||||||
clearable
|
|
||||||
size="mini"
|
|
||||||
placeholder="请输入你要搜索的内容"
|
|
||||||
style="width: 200px;"
|
|
||||||
class="filter-item"
|
|
||||||
/>
|
|
||||||
<date-range-picker v-model="query.createTime" class="date-item" />
|
|
||||||
<rrOperation />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { header } from '@crud/crud'
|
|
||||||
import rrOperation from '@crud/RR.operation'
|
|
||||||
import DateRangePicker from '@/components/DateRangePicker'
|
|
||||||
export default {
|
|
||||||
components: { rrOperation, DateRangePicker },
|
|
||||||
mixins: [header()]
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -33,6 +33,14 @@
|
|||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="接口">
|
||||||
|
<el-input
|
||||||
|
v-model="requestMethod"
|
||||||
|
size="mini"
|
||||||
|
placeholder="请输入接口"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="关键字">
|
<el-form-item label="关键字">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="message"
|
v-model="message"
|
||||||
@@ -186,6 +194,7 @@ let queryParam = {
|
|||||||
startTime: null,
|
startTime: null,
|
||||||
endTime: null,
|
endTime: null,
|
||||||
traceId: null,
|
traceId: null,
|
||||||
|
requestMethod: null,
|
||||||
message: null,
|
message: null,
|
||||||
filterSql: true,
|
filterSql: true,
|
||||||
isRequest: true,
|
isRequest: true,
|
||||||
@@ -203,6 +212,7 @@ export default {
|
|||||||
system: '',
|
system: '',
|
||||||
timeRange: [],
|
timeRange: [],
|
||||||
message: '',
|
message: '',
|
||||||
|
requestMethod: '',
|
||||||
traceId: '',
|
traceId: '',
|
||||||
size: 20,
|
size: 20,
|
||||||
logData: [],
|
logData: [],
|
||||||
@@ -313,6 +323,7 @@ export default {
|
|||||||
queryParam.filterSql = this.filterSql === '1'
|
queryParam.filterSql = this.filterSql === '1'
|
||||||
queryParam.isRequest = this.filterSql === '1'
|
queryParam.isRequest = this.filterSql === '1'
|
||||||
queryParam.traceId = this.traceId
|
queryParam.traceId = this.traceId
|
||||||
|
queryParam.requestMethod = this.requestMethod
|
||||||
queryParam.size = this.size
|
queryParam.size = this.size
|
||||||
queryParam.page = this.page
|
queryParam.page = this.page
|
||||||
queryParam.system = this.system
|
queryParam.system = this.system
|
||||||
@@ -352,6 +363,7 @@ export default {
|
|||||||
}
|
}
|
||||||
queryParam.message = this.message.replace(/^\s*|\s*$/g, '')
|
queryParam.message = this.message.replace(/^\s*|\s*$/g, '')
|
||||||
queryParam.traceId = this.traceId
|
queryParam.traceId = this.traceId
|
||||||
|
queryParam.requestMethod = this.requestMethod
|
||||||
queryParam.system = this.system
|
queryParam.system = this.system
|
||||||
|
|
||||||
logOperation.clearLogs(queryParam).then(res => {
|
logOperation.clearLogs(queryParam).then(res => {
|
||||||
|
|||||||
Reference in New Issue
Block a user