自定义日志颜色
|
After Width: | Height: | Size: 117 KiB |
|
After Width: | Height: | Size: 117 KiB |
|
After Width: | Height: | Size: 117 KiB |
|
After Width: | Height: | Size: 117 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 23 KiB |
@@ -4,6 +4,7 @@ import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.slife.ext.GroupEntityFactory;
|
||||
import com.slife.ext.IdGenerator;
|
||||
import com.slife.ext.UserEntityFactory;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.activiti.engine.IdentityService;
|
||||
import org.activiti.engine.identity.Group;
|
||||
import org.activiti.engine.identity.User;
|
||||
@@ -26,24 +27,20 @@ import java.util.List;
|
||||
* @createTime : 2017/11/23.
|
||||
*/
|
||||
@Configuration
|
||||
@AllArgsConstructor
|
||||
public class ActivitiConfig {
|
||||
|
||||
@Autowired
|
||||
PlatformTransactionManager transactionManager;
|
||||
private final PlatformTransactionManager transactionManager;
|
||||
|
||||
@Autowired
|
||||
DruidDataSource druidDataSource;
|
||||
private final DruidDataSource druidDataSource;
|
||||
|
||||
@Autowired
|
||||
UserEntityFactory userEntityFactory;
|
||||
private final UserEntityFactory userEntityFactory;
|
||||
|
||||
@Autowired
|
||||
GroupEntityFactory groupEntityFactory;
|
||||
private final GroupEntityFactory groupEntityFactory;
|
||||
|
||||
@Bean
|
||||
public SpringProcessEngineConfiguration getProcessEngineConfiguration(){
|
||||
SpringProcessEngineConfiguration config =
|
||||
new SpringProcessEngineConfiguration();
|
||||
SpringProcessEngineConfiguration config = new SpringProcessEngineConfiguration();
|
||||
config.setDataSource(druidDataSource);
|
||||
config.setTransactionManager(transactionManager);
|
||||
config.setDatabaseType("mysql");
|
||||
@@ -65,7 +62,6 @@ public class ActivitiConfig {
|
||||
@Primary
|
||||
@Bean
|
||||
public TaskExecutor primaryTaskExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
return executor;
|
||||
return new ThreadPoolTaskExecutor();
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public class AuthRealm extends AuthorizingRealm {
|
||||
sysUser.getPassword().substring(16), ByteSource.Util.bytes(salt),
|
||||
getName());
|
||||
} else {
|
||||
log.error("[AuthRealm#doGetAuthenticationInfo] --> {} login error", sysUser.getName());
|
||||
log.error("[AuthRealm#doGetAuthenticationInfo] --> login error");
|
||||
throw new UnknownAccountException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,9 @@
|
||||
target/
|
||||
|
||||
.mvn/
|
||||
mvnw
|
||||
mvnw.cmd
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
nbproject/private/
|
||||
build/
|
||||
nbbuild/
|
||||
dist/
|
||||
nbdist/
|
||||
.nb-gradle/
|
||||
### SLIFE ###
|
||||
target
|
||||
logs
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.slife.config.datasource;
|
||||
|
||||
/**
|
||||
* @author felixu
|
||||
* @date 2018.12.29
|
||||
*/
|
||||
public class MyBatisPlusConfig {
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.slife.config.log;
|
||||
|
||||
import ch.qos.logback.classic.Level;
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import ch.qos.logback.core.pattern.color.ANSIConstants;
|
||||
import ch.qos.logback.core.pattern.color.ForegroundCompositeConverterBase;
|
||||
|
||||
/**
|
||||
* 自定义 logback 控制台输出日志的颜色
|
||||
*
|
||||
* @author felixu
|
||||
* @date 2019.08.21
|
||||
*/
|
||||
public class LogbackColorful extends ForegroundCompositeConverterBase<ILoggingEvent> {
|
||||
|
||||
@Override
|
||||
protected String getForegroundColorCode(ILoggingEvent event) {
|
||||
Level level = event.getLevel();
|
||||
switch (level.toInt()) {
|
||||
case Level.ERROR_INT:
|
||||
return ANSIConstants.RED_FG;
|
||||
case Level.WARN_INT:
|
||||
return ANSIConstants.YELLOW_FG;
|
||||
case Level.DEBUG_INT:
|
||||
return ANSIConstants.BLUE_FG;
|
||||
case Level.INFO_INT:
|
||||
default:
|
||||
return ANSIConstants.BLACK_FG;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,61 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<include resource="org/springframework/boot/logging/logback/base.xml" />
|
||||
<logger name="org.springframework.web" level="DEBUG"/>
|
||||
<configuration scan="true" scanPeriod="10 seconds">
|
||||
|
||||
<!--自定义颜色配置-->
|
||||
<conversionRule conversionWord="customColor" converterClass="com.slife.config.log.LogbackColorful"/>
|
||||
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<encoder>
|
||||
<pattern>
|
||||
%customColor[ %-5level] [%date{yyyy-MM-dd HH:mm:ss}] %logger{96} [%line] - %msg%n
|
||||
</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
|
||||
<fileNamePattern>logs/logging-server-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy
|
||||
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
|
||||
<maxFileSize>32 MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
</rollingPolicy>
|
||||
|
||||
<prudent>true</prudent>
|
||||
</appender>
|
||||
|
||||
<!-- Console output -->
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
|
||||
<encoder>
|
||||
<pattern>
|
||||
%customColor([%-5level] [%d{yyyy-MM-dd HH:mm:ss}] %logger{96} [%line] - %msg%n)
|
||||
</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
|
||||
</appender>
|
||||
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="FILE" />
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
|
||||
<logger name="com.slife" level="DEBUG" />
|
||||
<logger name="org.activiti" level="DEBUG" />
|
||||
<logger name="org.springframework.web" level="INFO"/>
|
||||
<logger name="org.mybatis.spring" level="INFO" />
|
||||
|
||||
<springProfile name="staging">
|
||||
<!-- configuration to be enabled when the "staging" profile is active -->
|
||||
</springProfile>
|
||||
|
||||
<springProfile name="dev, staging">
|
||||
<!-- configuration to be enabled when the "dev" or "staging" profiles are active -->
|
||||
</springProfile>
|
||||
|
||||
<springProfile name="production">
|
||||
<!-- configuration to be enabled when the "production" profile is not active -->
|
||||
</springProfile>
|
||||
</configuration>
|
||||