微调项目架构
This commit is contained in:
77
pom.xml
77
pom.xml
@@ -110,65 +110,50 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>spring-snapshots</id>
|
|
||||||
<name>Spring Snapshots</name>
|
|
||||||
<url>https://repo.spring.io/snapshot</url>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>spring-milestones</id>
|
|
||||||
<name>Spring Milestones</name>
|
|
||||||
<url>https://repo.spring.io/milestone</url>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<pluginRepositories>
|
|
||||||
<pluginRepository>
|
|
||||||
<id>spring-snapshots</id>
|
|
||||||
<name>Spring Snapshots</name>
|
|
||||||
<url>https://repo.spring.io/snapshot</url>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</pluginRepository>
|
|
||||||
<pluginRepository>
|
|
||||||
<id>spring-milestones</id>
|
|
||||||
<name>Spring Milestones</name>
|
|
||||||
<url>https://repo.spring.io/milestone</url>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</pluginRepository>
|
|
||||||
</pluginRepositories>
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<finalName>jshERP2.0</finalName>
|
<finalName>jshERP2.0</finalName>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
<version>2.4</version>
|
<version>2.0.3.RELEASE</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>make-assembly</id>
|
<id>build-info</id>
|
||||||
|
<phase>generate-sources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>build-info</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>repackage</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<mainClass>com.jsh.erp.ErpApplication</mainClass>
|
||||||
|
<layout>JAR</layout>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
<version>2.5.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>make-zip</id>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>single</goal>
|
<goal>single</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<appendAssemblyId>false</appendAssemblyId>
|
|
||||||
<skipAssembly>false</skipAssembly>
|
|
||||||
<outputDirectory>./bin</outputDirectory>
|
|
||||||
<descriptors>
|
<descriptors>
|
||||||
<descriptor>src/main/assembly/package.xml</descriptor>
|
<descriptor>src/main/assembly/assembly.xml</descriptor>
|
||||||
</descriptors>
|
</descriptors>
|
||||||
|
<outputDirectory>./dist</outputDirectory>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
|||||||
71
src/main/assembly/assembly.xml
Normal file
71
src/main/assembly/assembly.xml
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<assembly
|
||||||
|
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0
|
||||||
|
http://maven.apache.org/xsd/assembly-1.1.0.xsd
|
||||||
|
http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 ">
|
||||||
|
|
||||||
|
<id>bin</id>
|
||||||
|
|
||||||
|
<formats>
|
||||||
|
<format>zip</format>
|
||||||
|
</formats>
|
||||||
|
|
||||||
|
<includeBaseDirectory>true</includeBaseDirectory>
|
||||||
|
|
||||||
|
<fileSets>
|
||||||
|
<fileSet>
|
||||||
|
<directory>erp_web</directory>
|
||||||
|
<outputDirectory>/erp_web</outputDirectory>
|
||||||
|
</fileSet>
|
||||||
|
<fileSet>
|
||||||
|
<directory>${project.basedir}/target</directory>
|
||||||
|
<includes>
|
||||||
|
<include>*.jar</include>
|
||||||
|
</includes>
|
||||||
|
<outputDirectory>/lib</outputDirectory>
|
||||||
|
</fileSet>
|
||||||
|
<fileSet>
|
||||||
|
<directory>${project.basedir}/src/main/resources</directory>
|
||||||
|
<includes>
|
||||||
|
<include>*.properties</include>
|
||||||
|
<include>*.yml</include>
|
||||||
|
<include>*.yaml</include>
|
||||||
|
<include>*.xml</include>
|
||||||
|
</includes>
|
||||||
|
<outputDirectory>/config</outputDirectory>
|
||||||
|
</fileSet>
|
||||||
|
<fileSet>
|
||||||
|
<directory>${project.basedir}/src/main/bin</directory>
|
||||||
|
<outputDirectory>/bin</outputDirectory>
|
||||||
|
<includes>
|
||||||
|
<include>run-manage.sh</include>
|
||||||
|
</includes>
|
||||||
|
<lineEnding>unix</lineEnding>
|
||||||
|
</fileSet>
|
||||||
|
<fileSet>
|
||||||
|
<directory>${project.basedir}/src/main/bin/</directory>
|
||||||
|
<outputDirectory>/</outputDirectory>
|
||||||
|
<includes>
|
||||||
|
<include>start.bat</include>
|
||||||
|
<include>restart.sh</include>
|
||||||
|
<include>start.sh</include>
|
||||||
|
<include>stop.sh</include>
|
||||||
|
<include>status.sh</include>
|
||||||
|
</includes>
|
||||||
|
</fileSet>
|
||||||
|
<fileSet>
|
||||||
|
<directory>docs</directory>
|
||||||
|
<outputDirectory>/docs</outputDirectory>
|
||||||
|
</fileSet>
|
||||||
|
<fileSet>
|
||||||
|
<directory>${project.basedir}</directory>
|
||||||
|
<includes>
|
||||||
|
<include>*.md</include>
|
||||||
|
<include>*.txt</include>
|
||||||
|
</includes>
|
||||||
|
<outputDirectory>/</outputDirectory>
|
||||||
|
</fileSet>
|
||||||
|
</fileSets>
|
||||||
|
</assembly>
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0
|
|
||||||
http://maven.apache.org/xsd/assembly-1.1.0.xsd
|
|
||||||
http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 ">
|
|
||||||
<id>package</id>
|
|
||||||
<formats>
|
|
||||||
<format>zip</format>
|
|
||||||
</formats>
|
|
||||||
<includeBaseDirectory>false</includeBaseDirectory>
|
|
||||||
<moduleSets>
|
|
||||||
<moduleSet>
|
|
||||||
<includes>
|
|
||||||
</includes>
|
|
||||||
</moduleSet>
|
|
||||||
</moduleSets>
|
|
||||||
<fileSets>
|
|
||||||
<fileSet>
|
|
||||||
<directory>src/main/conf</directory>
|
|
||||||
<outputDirectory>/</outputDirectory>
|
|
||||||
</fileSet>
|
|
||||||
<fileSet>
|
|
||||||
<directory>erp_web</directory>
|
|
||||||
<outputDirectory>/erp_web</outputDirectory>
|
|
||||||
</fileSet>
|
|
||||||
</fileSets>
|
|
||||||
<files>
|
|
||||||
<file>
|
|
||||||
<source>src/main/resources/application.properties</source>
|
|
||||||
<outputDirectory>/conf</outputDirectory>
|
|
||||||
</file>
|
|
||||||
<file>
|
|
||||||
<source>src/main/resources/logback-spring.xml</source>
|
|
||||||
<outputDirectory>/conf</outputDirectory>
|
|
||||||
</file>
|
|
||||||
</files>
|
|
||||||
<dependencySets>
|
|
||||||
<dependencySet>
|
|
||||||
<outputDirectory>lib</outputDirectory>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependencySet>
|
|
||||||
</dependencySets>
|
|
||||||
</assembly>
|
|
||||||
1
src/main/bin/restart.sh
Normal file
1
src/main/bin/restart.sh
Normal file
@@ -0,0 +1 @@
|
|||||||
|
./bin/run-manage.sh restart
|
||||||
163
src/main/bin/run-manage.sh
Normal file
163
src/main/bin/run-manage.sh
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
FILE_PATH=
|
||||||
|
SERVER_NAME=jshERP
|
||||||
|
readonly APP_HOME=${FILE_PATH:-$(dirname $(cd `dirname $0`; pwd))}
|
||||||
|
|
||||||
|
#readonly JAVA_HOME=""
|
||||||
|
|
||||||
|
readonly CONFIG_HOME="$APP_HOME/config/"
|
||||||
|
readonly LIB_HOME="$APP_HOME/lib"
|
||||||
|
readonly LOGS_HOME="$APP_HOME/logs"
|
||||||
|
|
||||||
|
readonly PID_FILE="$LOGS_HOME/application.pid"
|
||||||
|
readonly APP_MAIN_CLASS="jshERP2.0.jar"
|
||||||
|
readonly LOG_CONFIG="$CONFIG_HOME/logback-spring.xml"
|
||||||
|
|
||||||
|
readonly JAVA_RUN="-Dlogs.home=$LOGS_HOME -Dlogging.config=$LOG_CONFIG -Dspring.config.location=file:$CONFIG_HOME -Dspring.pid.file=$PID_FILE -Dspring.pid.fail-on-write-error=true"
|
||||||
|
readonly JAVA_OPTS="-server -Xms128m -Xmx376m -XX:PermSize=128M -XX:MaxPermSize=256M $JAVA_RUN"
|
||||||
|
|
||||||
|
readonly JAVA="java"
|
||||||
|
|
||||||
|
PID=0
|
||||||
|
|
||||||
|
|
||||||
|
if [ ! -x "$LOGS_HOME" ]
|
||||||
|
then
|
||||||
|
mkdir $LOGS_HOME
|
||||||
|
fi
|
||||||
|
chmod +x -R "$JAVA_HOME/bin/"
|
||||||
|
|
||||||
|
functions="/etc/functions.sh"
|
||||||
|
if test -f $functions ; then
|
||||||
|
. $functions
|
||||||
|
else
|
||||||
|
success()
|
||||||
|
{
|
||||||
|
echo " SUCCESS! $@"
|
||||||
|
}
|
||||||
|
failure()
|
||||||
|
{
|
||||||
|
echo " ERROR! $@"
|
||||||
|
}
|
||||||
|
warning()
|
||||||
|
{
|
||||||
|
echo "WARNING! $@"
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
|
function install(){
|
||||||
|
|
||||||
|
if [[ ! -n $FILE_PATH ]];then
|
||||||
|
sed -i "s#FILE_PATH=#FILE_PATH=$APP_HOME#" $APP_HOME/$0
|
||||||
|
|
||||||
|
if [[ -e /usr/sbin/$SERVER_NAME || -L /usr/sbin/$SERVER_NAME ]];then
|
||||||
|
|
||||||
|
rm -rf /usr/sbin/$SERVER_NAME && ln -s $APP_HOME/$0 /usr/sbin/$SERVER_NAME
|
||||||
|
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkpid() {
|
||||||
|
PID=$(ps -ef | grep $APP_MAIN_CLASS | grep -v 'grep' | awk '{print int($2)}')
|
||||||
|
if [[ -n "$PID" ]]
|
||||||
|
then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function start() {
|
||||||
|
checkpid
|
||||||
|
if [[ $? -eq 0 ]]
|
||||||
|
then
|
||||||
|
warning "[$APP_MAIN_CLASS]: already started! (PID=$PID)"
|
||||||
|
else
|
||||||
|
echo -n "[$APP_MAIN_CLASS]: Starting ..."
|
||||||
|
JAVA_CMD="nohup $JAVA $JAVA_OPTS -jar $LIB_HOME/$APP_MAIN_CLASS > /dev/null 2>&1 &"
|
||||||
|
# echo "Exec cmmand : $JAVA_CMD"
|
||||||
|
sh -c "$JAVA_CMD"
|
||||||
|
sleep 3
|
||||||
|
checkpid
|
||||||
|
if [[ $? -eq 0 ]]
|
||||||
|
then
|
||||||
|
success "(PID=$PID) "
|
||||||
|
else
|
||||||
|
failure " "
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function stop() {
|
||||||
|
checkpid
|
||||||
|
if [[ $? -eq 0 ]];
|
||||||
|
then
|
||||||
|
echo -n "[$APP_MAIN_CLASS]: Shutting down ...(PID=$PID) "
|
||||||
|
kill -9 $PID
|
||||||
|
if [[ $? -eq 0 ]];
|
||||||
|
then
|
||||||
|
echo 0 > $PID_FILE
|
||||||
|
success " "
|
||||||
|
else
|
||||||
|
failure " "
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warning "[$APP_MAIN_CLASS]: is not running ..."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function status() {
|
||||||
|
checkpid
|
||||||
|
if [[ $? -eq 0 ]]
|
||||||
|
then
|
||||||
|
success "[$APP_MAIN_CLASS]: is running! (PID=$PID)"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
failure "[$APP_MAIN_CLASS]: is not running"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function info() {
|
||||||
|
echo "System Information:"
|
||||||
|
echo
|
||||||
|
echo "****************************"
|
||||||
|
echo `head -n 1 /etc/issue`
|
||||||
|
echo `uname -a`
|
||||||
|
echo
|
||||||
|
echo "JAVA_HOME=$JAVA_HOME"
|
||||||
|
echo
|
||||||
|
echo "JAVA Environment Information:"
|
||||||
|
echo `$JAVA -version`
|
||||||
|
echo
|
||||||
|
echo "APP_HOME=$APP_HOME"
|
||||||
|
echo "APP_MAIN_CLASS=$APP_MAIN_CLASS"
|
||||||
|
echo
|
||||||
|
echo "****************************"
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
'start')
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
'stop')
|
||||||
|
stop
|
||||||
|
;;
|
||||||
|
'restart')
|
||||||
|
stop
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
'status')
|
||||||
|
status
|
||||||
|
;;
|
||||||
|
'info')
|
||||||
|
info
|
||||||
|
;;
|
||||||
|
'install')
|
||||||
|
install
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {help|start|stop|restart|status|info|install}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
exit 0
|
||||||
6
src/main/bin/start.bat
Normal file
6
src/main/bin/start.bat
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
title jshERP
|
||||||
|
|
||||||
|
java -Xms1000m -Xmx2000m -jar .\lib\jshERP2.0.jar
|
||||||
|
pause over
|
||||||
1
src/main/bin/start.sh
Normal file
1
src/main/bin/start.sh
Normal file
@@ -0,0 +1 @@
|
|||||||
|
./bin/run-manage.sh start
|
||||||
1
src/main/bin/status.sh
Normal file
1
src/main/bin/status.sh
Normal file
@@ -0,0 +1 @@
|
|||||||
|
./bin/run-manage.sh status
|
||||||
1
src/main/bin/stop.sh
Normal file
1
src/main/bin/stop.sh
Normal file
@@ -0,0 +1 @@
|
|||||||
|
./bin/run-manage.sh stop
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
@echo off
|
|
||||||
|
|
||||||
title jshERP
|
|
||||||
|
|
||||||
java -Xms1000m -Xmx2000m -cp .\conf;.\lib\*; -XX:+CreateMinidumpOnCrash com.jsh.erp.ErpApplication
|
|
||||||
pause over
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
nohup java -XX:+CreateMinidumpOnCrash -cp ./conf:./lib/*: com.jsh.erp.ErpApplication > /dev/null 2>&1 &
|
|
||||||
@@ -1,197 +1,34 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<configuration>
|
||||||
<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 -->
|
<property name="LOG_FILE" value="${logs.home}/jshERP"/>
|
||||||
<!-- scan:当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true -->
|
<property name="LOG_PATTERN" value="%d{yyyy/MM/dd-HH:mm:ss} %-5level [%thread] %logger - %msg%n"/>
|
||||||
<!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
|
|
||||||
<!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
|
|
||||||
<configuration scan="true" scanPeriod="10 seconds">
|
|
||||||
|
|
||||||
<!--<include resource="org/springframework/boot/logging/logback/base.xml" />-->
|
|
||||||
|
|
||||||
<contextName>logback</contextName>
|
|
||||||
<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
|
|
||||||
<property name="log.path" value="../logs/jshERP" />
|
|
||||||
|
|
||||||
<!-- 彩色日志 -->
|
|
||||||
<!-- 彩色日志依赖的渲染类 -->
|
|
||||||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
|
|
||||||
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
|
|
||||||
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
|
|
||||||
<!-- 彩色日志格式 -->
|
|
||||||
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
|
||||||
|
|
||||||
|
|
||||||
<!--输出到控制台-->
|
|
||||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
|
|
||||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
|
||||||
<level>debug</level>
|
|
||||||
</filter>
|
|
||||||
<encoder>
|
<encoder>
|
||||||
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
|
<pattern>${LOG_PATTERN}</pattern>
|
||||||
<!-- 设置字符集 -->
|
|
||||||
<charset>UTF-8</charset>
|
|
||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
|
<appender name="TIME_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
<!--输出到文件-->
|
<file>${LOG_FILE}.log</file>
|
||||||
|
|
||||||
<!-- 时间滚动输出 level为 DEBUG 日志 -->
|
|
||||||
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<!-- 正在记录的日志文件的路径及文件名 -->
|
|
||||||
<file>${log.path}/log_debug.log</file>
|
|
||||||
<!--日志文件输出格式-->
|
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
<pattern>${LOG_PATTERN}</pattern>
|
||||||
<charset>UTF-8</charset> <!-- 设置字符集 -->
|
|
||||||
</encoder>
|
</encoder>
|
||||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
<!-- 日志归档 -->
|
<fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||||
<fileNamePattern>${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
<maxHistory>10</maxHistory>
|
||||||
|
<totalSizeCap>1GB</totalSizeCap>
|
||||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||||
<maxFileSize>100MB</maxFileSize>
|
<maxFileSize>100MB</maxFileSize>
|
||||||
</timeBasedFileNamingAndTriggeringPolicy>
|
</timeBasedFileNamingAndTriggeringPolicy>
|
||||||
<!--日志文件保留天数-->
|
|
||||||
<maxHistory>15</maxHistory>
|
|
||||||
</rollingPolicy>
|
</rollingPolicy>
|
||||||
<!-- 此日志文件只记录debug级别的 -->
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
||||||
<level>debug</level>
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
|
||||||
<onMismatch>DENY</onMismatch>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<!-- 时间滚动输出 level为 INFO 日志 -->
|
<root level="ERROR">
|
||||||
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<!-- 正在记录的日志文件的路径及文件名 -->
|
|
||||||
<file>${log.path}/log_info.log</file>
|
|
||||||
<!--日志文件输出格式-->
|
|
||||||
<encoder>
|
|
||||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
|
||||||
<charset>UTF-8</charset>
|
|
||||||
</encoder>
|
|
||||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<!-- 每天日志归档路径以及格式 -->
|
|
||||||
<fileNamePattern>${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
|
||||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
|
||||||
<maxFileSize>100MB</maxFileSize>
|
|
||||||
</timeBasedFileNamingAndTriggeringPolicy>
|
|
||||||
<!--日志文件保留天数-->
|
|
||||||
<maxHistory>15</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<!-- 此日志文件只记录info级别的 -->
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
||||||
<level>info</level>
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
|
||||||
<onMismatch>DENY</onMismatch>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- 时间滚动输出 level为 WARN 日志 -->
|
|
||||||
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<!-- 正在记录的日志文件的路径及文件名 -->
|
|
||||||
<file>${log.path}/log_warn.log</file>
|
|
||||||
<!--日志文件输出格式-->
|
|
||||||
<encoder>
|
|
||||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
|
||||||
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
|
|
||||||
</encoder>
|
|
||||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<fileNamePattern>${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
|
||||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
|
||||||
<maxFileSize>100MB</maxFileSize>
|
|
||||||
</timeBasedFileNamingAndTriggeringPolicy>
|
|
||||||
<!--日志文件保留天数-->
|
|
||||||
<maxHistory>15</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<!-- 此日志文件只记录warn级别的 -->
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
||||||
<level>warn</level>
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
|
||||||
<onMismatch>DENY</onMismatch>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- 时间滚动输出 level为 ERROR 日志 -->
|
|
||||||
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<!-- 正在记录的日志文件的路径及文件名 -->
|
|
||||||
<file>${log.path}/log_error.log</file>
|
|
||||||
<!--日志文件输出格式-->
|
|
||||||
<encoder>
|
|
||||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
|
||||||
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
|
|
||||||
</encoder>
|
|
||||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<fileNamePattern>${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
|
||||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
|
||||||
<maxFileSize>100MB</maxFileSize>
|
|
||||||
</timeBasedFileNamingAndTriggeringPolicy>
|
|
||||||
<!--日志文件保留天数-->
|
|
||||||
<maxHistory>15</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<!-- 此日志文件只记录ERROR级别的 -->
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
||||||
<level>ERROR</level>
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
|
||||||
<onMismatch>DENY</onMismatch>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
<logger>用来设置某一个包或者具体的某一个类的日志打印级别、
|
|
||||||
以及指定<appender>。<logger>仅有一个name属性,
|
|
||||||
一个可选的level和一个可选的addtivity属性。
|
|
||||||
name:用来指定受此logger约束的某一个包或者具体的某一个类。
|
|
||||||
level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,
|
|
||||||
还有一个特俗值INHERITED或者同义词NULL,代表强制执行上级的级别。
|
|
||||||
如果未设置此属性,那么当前logger将会继承上级的级别。
|
|
||||||
addtivity:是否向上级logger传递打印信息。默认是true。
|
|
||||||
-->
|
|
||||||
<!--<logger name="org.springframework.web" level="info"/>-->
|
|
||||||
<!--<logger name="org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor" level="INFO"/>-->
|
|
||||||
<!--
|
|
||||||
使用mybatis的时候,sql语句是debug下才会打印,而这里我们只配置了info,所以想要查看sql语句的话,有以下两种操作:
|
|
||||||
第一种把<root level="info">改成<root level="DEBUG">这样就会打印sql,不过这样日志那边会出现很多其他消息
|
|
||||||
第二种就是单独给dao下目录配置debug模式,代码如下,这样配置sql语句会打印,其他还是正常info级别:
|
|
||||||
-->
|
|
||||||
|
|
||||||
|
|
||||||
<!--
|
|
||||||
root节点是必选节点,用来指定最基础的日志输出级别,只有一个level属性
|
|
||||||
level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,
|
|
||||||
不能设置为INHERITED或者同义词NULL。默认是DEBUG
|
|
||||||
可以包含零个或多个元素,标识这个appender将会添加到这个logger。
|
|
||||||
-->
|
|
||||||
|
|
||||||
<!--开发环境:打印控制台
|
|
||||||
|
|
||||||
<springProfile name="dev">
|
|
||||||
<logger name="com.nmys.view" level="debug"/>
|
|
||||||
</springProfile>
|
|
||||||
-->
|
|
||||||
<root level="info">
|
|
||||||
<appender-ref ref="CONSOLE"/>
|
<appender-ref ref="CONSOLE"/>
|
||||||
<appender-ref ref="DEBUG_FILE" />
|
<appender-ref ref="TIME_FILE"/>
|
||||||
<appender-ref ref="INFO_FILE" />
|
|
||||||
<appender-ref ref="WARN_FILE" />
|
|
||||||
<appender-ref ref="ERROR_FILE" />
|
|
||||||
</root>
|
</root>
|
||||||
|
<logger name="com.jsh" additivity="false" level="DEBUG">
|
||||||
<!--生产环境:输出到文件-->
|
<appender-ref ref="CONSOLE"/>
|
||||||
<!--<springProfile name="pro">-->
|
<appender-ref ref="TIME_FILE"/>
|
||||||
<!--<root level="info">-->
|
</logger>
|
||||||
<!--<appender-ref ref="CONSOLE" />-->
|
|
||||||
<!--<appender-ref ref="DEBUG_FILE" />-->
|
|
||||||
<!--<appender-ref ref="INFO_FILE" />-->
|
|
||||||
<!--<appender-ref ref="ERROR_FILE" />-->
|
|
||||||
<!--<appender-ref ref="WARN_FILE" />-->
|
|
||||||
<!--</root>-->
|
|
||||||
<!--</springProfile>-->
|
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
Reference in New Issue
Block a user