# operate-log-spring-boot-starter
**Repository Path**: flypiggy-stack/operate-log-spring-boot-starter
## Basic Information
- **Project Name**: operate-log-spring-boot-starter
- **Description**: 可插拔式日志操作记录
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 6
- **Forks**: 2
- **Created**: 2022-09-08
- **Last Updated**: 2024-09-29
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# operate-log-spring-boot-starter
#### Introduction
Operate-Log uses starter dependencies,realize web interface log output to a variety of storage objects; With the
advantage of low code intrusion, it can be plugged and unplugged by simply configuring yml files.
#### Installation tutorial
Direct reference maven dependency
```xml
io.github.flypiggy-stack
operate-log-spring-boot-starter
1.2.4
```
1. Direct reference maven central warehouse dependency
2. Directly down the code, mvn deploy to the private nexus or Ali mirror warehouse (must be placed in the warehouse,
otherwise maven dependency cannot be passed)
#### Instructions for use
##### JDBC connection mode database
1. Introducing dependency
```xml
org.springframework.boot
spring-boot-starter-jdbc
```
2. Configure yml
Tip: jdbc connection information uses spring-boot configuration.
```yaml
spring:
operate-log:
enable: true #Enabled
store-type: jdbc #jdbc connection method
jdbc:
table-name: log_table #Log output table name
suffix: month #Supports time format suffix storage of table names
```
##### Enable ES
1. Introducing dependency
```xml
co.elastic.clients
elasticsearch-java
7.17.4
```
```xml
jakarta.json
jakarta.json-api
2.0.1
```
**The dependent version of es must be compatible with the es instance to avoid unknown exceptions. Currently, the
supported es version >=7.15**
2. Configure yml
```yaml
spring:
operate-log:
enable: true
store-type: elasticsearch
elasticsearch:
nodes: ["ip:port","ip:port"] #es cluster node
username: (Fill in as required)
password: (Fill in as required)
index:
name: web_log #Index name
type: final_unchanged #There are two types of indexes [final unchanged\date suffix]; The final unchanged is a fixed index; The date suffix is the index name plus a time suffix. The specific time suffix is determined by the suffix type.
suffix: year #There is a [year\month\day] type selection, and the year generated by year is the suffix. For example, the index is a web_log_2022
```
##### Enable mongodb
1. Introducing dependency
```xml
org.springframework.boot
spring-boot-starter-data-mongodb
```
2. Configure yml
Tip: Use spring-boot configuration for mongodb connection information
```yaml
spring:
operate-log:
enable: true
store-type: mongodb
mongodb:
collection-name: web_log #Collection name
suffix: day #There is a [year\month\day] type selection, and the year generated by year is the suffix. For example, the index is a web_log_2022
```
#### Yaml other configuration instructions
```yaml
spring:
operate-log:
class-info-value: tags #The 'classInfo' field references the value in the '@Api' annotation; when 'tags', only the first parameter is used; the default TAGS.
exclude: #Configure to exclude interception
api:
put:
- /xx/xx/xx #Put request method, this interface does not need to intercept; Wildcard '*' matching is supported.
http-method: delete,head,post #The delete\head\post request method does not need to be intercepted. It is in the form of an array.
use-swagger-annotation: true #Enable the operation log to use swagger annotation information. If you use it, you need to introduce swagger dependencies.
thrown-exception-name: [ 'NullPointerException' ] #If it is empty, all exceptions are thrown; if an exception is specified, only the specified exception is thrown.
```
#### Operator
Can be used directly code LogOperatorContext.set("Operator");
- 1.Direct use LogOperatorContext.set("Operator")
- 2.Register a bean of OperatorGetter
**The value in 2 does not take effect when 1 is used**
#### New features in the future
1. Add query log methods and http api