diff --git a/broker/pom.xml b/broker/pom.xml index 810818b5b..812330ffb 100644 --- a/broker/pom.xml +++ b/broker/pom.xml @@ -19,29 +19,37 @@ - org.slf4j - slf4j-api - 1.7.5 + cn.wildfirechat + common + ${project.version} - - org.slf4j - slf4j-log4j12 - 1.7.5 + org.apache.logging.log4j + log4j-core + 2.17.0 - - cn.wildfirechat - common - ${project.version} + org.apache.logging.log4j + log4j-api + 2.17.0 - - + - log4j - log4j - 1.2.17 + org.apache.logging.log4j + log4j-slf4j-impl + 2.17.0 + + + + org.slf4j + slf4j-api + 1.7.25 + + + com.lmax + disruptor + 3.4.1 diff --git a/broker/src/main/resources/log4j.properties b/broker/src/main/resources/log4j.properties deleted file mode 100755 index c321cfc29..000000000 --- a/broker/src/main/resources/log4j.properties +++ /dev/null @@ -1,73 +0,0 @@ -# Set root logger level to DEBUG and its only appender to A1. -#log4j.rootLogger=ERROR, A1 -#log4j.rootLogger=INFO, stdout, file -log4j.rootLogger=INFO, file, messagelog - -log4j.logger.io.moquette=INFO -log4j.logger.io.moquette.spi.impl.ProtocolProcessor=INFO -log4j.logger.io.moquette.spi.impl.ProtocolProcessorBootstrapper=WARN - -#Protocol parsing -log4j.logger.io.moquette.server.netty.NettyMQTTHandler=WARN -#log4j.logger.io.moquette.server.netty.NettyMQTTHandler=DEBUG -log4j.logger.io.moquette.parser.netty=WARN -#Storage server -#log4j.logger.io.moquette.spi.impl.subscriptions.SubscriptionsDirectorytory=DEBUG -#log4j.logger.io.moquette.spi.impl.HawtDBStorageService=DEBUG - -# stdout appender is set to be a ConsoleAppender. -#log4j.appender.stdout=org.apache.log4j.ConsoleAppender -#log4j.appender.stdout.Threshold=WARN -#log4j.appender.stdout.Threshold=INFO -#log4j.appender.stdout.Threshold=DEBUG -#log4j.appender.stdout.Threshold=TRACE -#log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -#log4j.appender.stdout.layout.ConversionPattern=%-4r [%t] %-5p %c{1} %x - %m%n - -#file appender -log4j.appender.file=org.apache.log4j.RollingFileAppender -log4j.appender.file.Threshold=INFO -log4j.appender.file.File=logs/wildfirechat.log -log4j.appender.file.MaxFileSize=10MB -log4j.appender.file.MaxBackupIndex=20 -log4j.appender.file.layout=org.apache.log4j.PatternLayout -#log4j.appender.file.layout.ConversionPattern=%-4r [%t] %-5p %c{1} %x - %m%n -log4j.appender.file.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss,SSS} [%t] %-5p %c{1} %L %x - %m%n - -#################################### -# Message Logger Configuration # -##################################### -log4j.appender.messagelog=org.apache.log4j.RollingFileAppender -log4j.appender.messagelog.Threshold=WARN -log4j.appender.messagelog.File=logs/wildfirechat_messages.log -log4j.appender.messagelog.MaxFileSize=100MB -log4j.appender.messagelog.MaxBackupIndex=1 -log4j.appender.messagelog.layout=org.apache.log4j.PatternLayout -log4j.appender.messagelog.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss,SSS} [%t] %-5p %c{1} %L %x - %m%n - -log4j.category.messageLogger=WARN, messagelog - - -log4j.logger.cn.wildfirechat.push=INFO, push_log -log4j.additivity.cn.wildfirechat.push=false -log4j.appender.push_log=org.apache.log4j.RollingFileAppender -log4j.appender.push_log.File=logs/push.log -log4j.appender.push_log.Append=true -log4j.appender.push_log.MaxFileSize=10MB -log4j.appender.push_log.MaxBackupIndex=5 -log4j.appender.push_log.layout=org.apache.log4j.PatternLayout -log4j.appender.push_log.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%-5p][%c{1}] [%t] - %m%n -log4j.appender.push_log.encoding=UTF-8 - - -log4j.logger.com.xiaoleilu.loServer=INFO, http_log -log4j.additivity.com.xiaoleilu.loServer=false -log4j.appender.http_log=org.apache.log4j.RollingFileAppender -log4j.appender.http_log.File=logs/http.log -log4j.appender.http_log.Append=true -log4j.appender.http_log.MaxFileSize=10MB -log4j.appender.http_log.MaxBackupIndex=5 -log4j.appender.http_log.layout=org.apache.log4j.PatternLayout -log4j.appender.http_log.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%-5p][%c{1}] [%t] - %m%n -log4j.appender.http_log.encoding=UTF-8 - diff --git a/broker/src/main/resources/log4j2.xml b/broker/src/main/resources/log4j2.xml new file mode 100755 index 000000000..db18567b1 --- /dev/null +++ b/broker/src/main/resources/log4j2.xml @@ -0,0 +1,108 @@ + + + + + + + + ./logs + test.log + UTF-8 + + %d %-5p [%t] %C{2} (%F:%L) - %m%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/distribution/src/main/assembly/assembly.xml b/distribution/src/main/assembly/assembly.xml index b7a9cbb71..d5a8bbbb7 100755 --- a/distribution/src/main/assembly/assembly.xml +++ b/distribution/src/main/assembly/assembly.xml @@ -40,9 +40,9 @@ - src/main/resources/log4j.properties + src/main/resources/log4j2.xml config/ - log4j.properties + log4j2.xml diff --git a/distribution/src/main/resources/log4j.properties b/distribution/src/main/resources/log4j.properties deleted file mode 100755 index ab749f926..000000000 --- a/distribution/src/main/resources/log4j.properties +++ /dev/null @@ -1,73 +0,0 @@ -# Set root logger level to DEBUG and its only appender to A1. -#log4j.rootLogger=ERROR, A1 -#log4j.rootLogger=INFO, stdout, file -log4j.rootLogger=INFO, file, messagelog - -log4j.logger.io.moquette=INFO -log4j.logger.io.moquette.spi.impl.ProtocolProcessor=INFO -log4j.logger.io.moquette.spi.impl.ProtocolProcessorBootstrapper=WARN - -#Protocol parsing -log4j.logger.io.moquette.server.netty.NettyMQTTHandler=WARN -#log4j.logger.io.moquette.server.netty.NettyMQTTHandler=DEBUG -log4j.logger.io.moquette.parser.netty=WARN -#Storage server -#log4j.logger.io.moquette.spi.impl.subscriptions.SubscriptionsDirectorytory=DEBUG -#log4j.logger.io.moquette.spi.impl.HawtDBStorageService=DEBUG - -# stdout appender is set to be a ConsoleAppender. -#log4j.appender.stdout=org.apache.log4j.ConsoleAppender -#log4j.appender.stdout.Threshold=WARN -#log4j.appender.stdout.Threshold=INFO -#log4j.appender.stdout.Threshold=DEBUG -#log4j.appender.stdout.Threshold=TRACE -#log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -#log4j.appender.stdout.layout.ConversionPattern=%-4r [%t] %-5p %c{1} %x - %m%n - -#file appender -log4j.appender.file=org.apache.log4j.RollingFileAppender -log4j.appender.file.Threshold=INFO -log4j.appender.file.File=logs/wildfirechat.log -log4j.appender.file.MaxFileSize=20MB -log4j.appender.file.MaxBackupIndex=100 -log4j.appender.file.layout=org.apache.log4j.PatternLayout -#log4j.appender.file.layout.ConversionPattern=%-4r [%t] %-5p %c{1} %x - %m%n -log4j.appender.file.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss,SSS} [%t] %-5p %c{1} %L %x - %m%n - -#################################### -# Message Logger Configuration # -##################################### -log4j.appender.messagelog=org.apache.log4j.RollingFileAppender -log4j.appender.messagelog.Threshold=WARN -log4j.appender.messagelog.File=logs/wildfirechat_messages.log -log4j.appender.messagelog.MaxFileSize=100MB -log4j.appender.messagelog.MaxBackupIndex=3 -log4j.appender.messagelog.layout=org.apache.log4j.PatternLayout -log4j.appender.messagelog.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss,SSS} [%t] %-5p %c{1} %L %x - %m%n - -log4j.category.messageLogger=WARN, messagelog - - -log4j.logger.cn.wildfirechat.push=INFO, push_log -log4j.additivity.cn.wildfirechat.push=false -log4j.appender.push_log=org.apache.log4j.RollingFileAppender -log4j.appender.push_log.File=logs/push.log -log4j.appender.push_log.Append=true -log4j.appender.push_log.MaxFileSize=10MB -log4j.appender.push_log.MaxBackupIndex=5 -log4j.appender.push_log.layout=org.apache.log4j.PatternLayout -log4j.appender.push_log.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%-5p][%c{1}] [%t] - %m%n -log4j.appender.push_log.encoding=UTF-8 - - -log4j.logger.com.xiaoleilu.loServer=INFO, http_log -log4j.additivity.com.xiaoleilu.loServer=false -log4j.appender.http_log=org.apache.log4j.RollingFileAppender -log4j.appender.http_log.File=logs/http.log -log4j.appender.http_log.Append=true -log4j.appender.http_log.MaxFileSize=10MB -log4j.appender.http_log.MaxBackupIndex=5 -log4j.appender.http_log.layout=org.apache.log4j.PatternLayout -log4j.appender.http_log.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%-5p][%c{1}] [%t] - %m%n -log4j.appender.http_log.encoding=UTF-8 - diff --git a/distribution/src/main/resources/log4j2.xml b/distribution/src/main/resources/log4j2.xml new file mode 100755 index 000000000..25fff54b9 --- /dev/null +++ b/distribution/src/main/resources/log4j2.xml @@ -0,0 +1,108 @@ + + + + + + + + ./logs + test.log + UTF-8 + + %d %-5p [%t] %C{2} (%F:%L) - %m%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/distribution/src/main/scripts/wildfirechat.bat b/distribution/src/main/scripts/wildfirechat.bat index e0dafc9c1..832c45a50 100644 --- a/distribution/src/main/scripts/wildfirechat.bat +++ b/distribution/src/main/scripts/wildfirechat.bat @@ -16,9 +16,9 @@ goto end rem Set JavaHome if it exists if exist { "%JAVA_HOME%\bin\java" } ( set "JAVA="%JAVA_HOME%\bin\java"" -) else ( +) else { set "JAVA="java"" -) +} echo Using JAVA_HOME: "%JAVA_HOME%" echo Using WILDFIRECHAT_HOME: "%WILDFIRECHAT_HOME%" @@ -28,7 +28,7 @@ rem set LOG_FILE_LEVEL=fine set JAVA_OPTS= set JAVA_OPTS_SCRIPT=-XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true set WILDFIRECHAT_PATH=%WILDFIRECHAT_HOME% -set LOG_FILE=%WILDFIRECHAT_HOME%\config\log4j.properties +set LOG_FILE=%WILDFIRECHAT_HOME%\config\log4j2.xml set HZ_CONF_FILE=%WILDFIRECHAT_HOME%\config\hazelcast.xml set C3P0_CONF_FILE=%WILDFIRECHAT_HOME%\config\c3p0-config.xml @@ -72,8 +72,11 @@ rem set JAVA_OPTS=%JAVA_OPTS% -XX:+UseGCLogFileRotation rem set JAVA_OPTS=%JAVA_OPTS% -XX:NumberOfGCLogFiles=10 rem set JAVA_OPTS=%JAVA_OPTS% -XX:GCLogFileSize=10M" +echo echo 请设置JVM参数Xmx和Xms!!! +echo + rem set JAVA_OPTS=%JAVA_OPTS% -Xmx2G rem set JAVA_OPTS=%JAVA_OPTS% -Xms2G -%JAVA% -server %JAVA_OPTS% %JAVA_OPTS_SCRIPT% -Dlog4j.configuration=file:%LOG_FILE% -Dcom.mchange.v2.c3p0.cfg.xml=%C3P0_CONF_FILE% -Dhazelcast.configuration=file:%HZ_CONF_FILE% -Dwildfirechat.path=%WILDFIRECHAT_PATH% -cp %WILDFIRECHAT_HOME%\lib\* cn.wildfirechat.server.Server +%JAVA% -server %JAVA_OPTS% %JAVA_OPTS_SCRIPT% -Dlog4j.configurationFile=%LOG_FILE% -Dcom.mchange.v2.c3p0.cfg.xml=%C3P0_CONF_FILE% -Dhazelcast.configuration=file:%HZ_CONF_FILE% -Dwildfirechat.path=%WILDFIRECHAT_PATH% -cp %WILDFIRECHAT_HOME%\lib\* cn.wildfirechat.server.Server diff --git a/distribution/src/main/scripts/wildfirechat.sh b/distribution/src/main/scripts/wildfirechat.sh index 3285cfaa9..bfef02f8f 100755 --- a/distribution/src/main/scripts/wildfirechat.sh +++ b/distribution/src/main/scripts/wildfirechat.sh @@ -34,7 +34,7 @@ else fi export JAVA -LOG_FILE=$WILDFIRECHAT_HOME/config/log4j.properties +LOG_FILE=$WILDFIRECHAT_HOME/config/log4j2.xml HZ_CONF_FILE=$WILDFIRECHAT_HOME/config/hazelcast.xml C3P0_CONF_FILE=$WILDFIRECHAT_HOME/config/c3p0-config.xml @@ -83,11 +83,12 @@ JAVA_OPTS="$JAVA_OPTS -XX:MaxGCPauseMillis=500" #JAVA_OPTS="$JAVA_OPTS -XX:NumberOfGCLogFiles=10" #JAVA_OPTS="$JAVA_OPTS -XX:GCLogFileSize=10M" -echo "" -echo "请设置JVM参数Xmx和Xms!!!" + +echo "警告:没有设置JVM内存参数!" +echo "请设置JVM参数Xmx和Xms,设置为您为IM服务预留的内存大小,注意需要刨除操作系统占用,如果有其它系统也需要相应去除占用。" echo "" #JAVA_OPTS="$JAVA_OPTS -Xmx2G" #JAVA_OPTS="$JAVA_OPTS -Xms2G" -$JAVA -server $JAVA_OPTS $JAVA_OPTS_SCRIPT -Dlog4j.configuration="file:$LOG_FILE" -Dcom.mchange.v2.c3p0.cfg.xml="$C3P0_CONF_FILE" -Dhazelcast.configuration="file:$HZ_CONF_FILE" -Dwildfirechat.path="$WILDFIRECHAT_PATH" -cp "$WILDFIRECHAT_HOME/lib/*" cn.wildfirechat.server.Server +$JAVA -server $JAVA_OPTS $JAVA_OPTS_SCRIPT -Dlog4j.configurationFile="file:$LOG_FILE" -Dlog4j2.formatMsgNoLookups=true -Dcom.mchange.v2.c3p0.cfg.xml="$C3P0_CONF_FILE" -Dhazelcast.configuration="file:$HZ_CONF_FILE" -Dwildfirechat.path="$WILDFIRECHAT_PATH" -cp "$WILDFIRECHAT_HOME/lib/*" cn.wildfirechat.server.Server