|
1 |
| -/* |
2 |
| - * Copyright 2005-2022 Du Law Office - The Summer Boot Framework Project |
3 |
| - * |
4 |
| - * The Summer Boot Project licenses this file to you under the Apache License, version 2.0 (the |
5 |
| - * "License"); you may not use this file except in compliance with the License and you have no |
6 |
| - * policy prohibiting employee contributions back to this file (unless the contributor to this |
7 |
| - * file is your current or retired employee). You may obtain a copy of the License at: |
8 |
| - * |
9 |
| - * https://www.apache.org/licenses/LICENSE-2.0 |
10 |
| - * |
11 |
| - * Unless required by applicable law or agreed to in writing, software distributed under the License |
12 |
| - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
13 |
| - * or implied. See the License for the specific language governing permissions and limitations under |
14 |
| - * the License. |
15 |
| - */ |
16 |
| -package org.summerboot.jexpress.boot; |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | +<!-- version 2.4.10 --> |
| 3 | +<Configuration status="WARN" monitorInterval="30"> |
| 4 | + <Properties> |
| 5 | + <Property name="logPattern" value="[${sys:logId}] %d{ISO8601} %p %c{}.%M() [%t] %m %ex%n"/> |
| 6 | + <!-- usage: %replace{pattern}{regex}{substitution} --> |
| 7 | + <Property name="logPattern2" value="[${sys:logId}] %d{ISO8601} %p %c{}.%M() [%t] %replace{%enc{%m}{CRLF}}{\\r|\\n|%0D|%0A|%0d|%0a}{|} %uEx%n"/> |
| 8 | + </Properties> |
| 9 | + <Appenders> |
| 10 | + <Console name="Console" target="SYSTEM_OUT"> |
| 11 | + <!-- <PatternLayout pattern="%d{ISO8601}{Canada/Eastern} %p %c{}.%M() [%t] %enc{%m}{CRLF} %ex%n"/>--> |
| 12 | + <PatternLayout pattern="${sys:logPattern}"/> |
| 13 | + </Console> |
17 | 14 |
|
18 |
| -import java.util.Random; |
| 15 | + <!-- |
| 16 | + 1. Requires JVM arg: -Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector |
| 17 | + 2. Required total disk spece: around 200MB |
| 18 | + 3. Archive logs: by DAY and split them by MINUTE |
| 19 | + 4. Default log level is tuned for development |
| 20 | + --> |
| 21 | + <RollingRandomAccessFile |
| 22 | + name="StatusLogFile" |
| 23 | + fileName="${sys:logPath}/${sys:appName}_status_${sys:serverName}.log" |
| 24 | + filePattern="${sys:logPath}/$${date:yyyy-MM-dd}/${sys:appName}_status_${sys:serverName}_%d{yyyy-MM-dd HH:mm}.%i.log.gz" |
| 25 | + immediateFlush="false" |
| 26 | + ignoreExceptions="false"> |
| 27 | + <PatternLayout pattern="${sys:logPattern}"/> |
| 28 | + <Policies> |
| 29 | + <SizeBasedTriggeringPolicy size="2MB"/> |
| 30 | + </Policies> |
| 31 | + <DefaultRolloverStrategy max="50"/> |
| 32 | + </RollingRandomAccessFile> |
| 33 | + <RollingRandomAccessFile |
| 34 | + name="RequestLogFile" |
| 35 | + fileName="${sys:logPath}/${sys:appName}_requests_${sys:serverName}.log" |
| 36 | + filePattern="${sys:logPath}/$${date:yyyy-MM-dd}/${sys:appName}_requests_${sys:serverName}_%d{yyyy-MM-dd HH:mm}.%i.log.gz" |
| 37 | + immediateFlush="false" |
| 38 | + ignoreExceptions="false"> |
| 39 | + <PatternLayout pattern="${sys:logPattern}"/> |
| 40 | + <Policies> |
| 41 | + <SizeBasedTriggeringPolicy size="10MB"/> |
| 42 | + </Policies> |
| 43 | + <DefaultRolloverStrategy max="500"/> |
| 44 | + </RollingRandomAccessFile> |
| 45 | + <RollingRandomAccessFile |
| 46 | + name="ScheduledLogFile" |
| 47 | + fileName="${sys:logPath}/${sys:appName}_schedule_${sys:serverName}.log" |
| 48 | + filePattern="${sys:logPath}/$${date:yyyy-MM-dd}/${sys:appName}_schedule_${sys:serverName}_%d{yyyy-MM-dd HH:mm}.%i.log.gz" |
| 49 | + immediateFlush="false" |
| 50 | + ignoreExceptions="false"> |
| 51 | + <PatternLayout pattern="${sys:logPattern}"/> |
| 52 | + <Policies> |
| 53 | + <SizeBasedTriggeringPolicy size="10MB"/> |
| 54 | + </Policies> |
| 55 | + <DefaultRolloverStrategy max="500"/> |
| 56 | + </RollingRandomAccessFile> |
| 57 | + </Appenders> |
| 58 | + <Loggers> |
| 59 | + <Root level="warn" includeLocation="true"> |
| 60 | + <AppenderRef ref="StatusLogFile"/> |
| 61 | + <!-- --> |
| 62 | + <AppenderRef ref="Console"/> |
| 63 | + </Root> |
| 64 | + <Logger level="info" name="com.hazelcast" includeLocation="true"/> |
| 65 | + <Logger level="warn" name="io.netty" includeLocation="true"/> |
| 66 | + <!-- Note: "java.lang.UnsupportedOperationException: sun.misc.Unsafe unavailable" can be seen, also can be ignored, when -Dio.netty.noUnsafe=true and io.netty.util.internal.CleanerJava9 log level is below INFO (either TRACE or DEBUG) --> |
| 67 | + <Logger level="info" name="io.netty.util.internal.CleanerJava9" includeLocation="true"/> |
| 68 | + <Logger level="debug" name="org.summerboot.jexpress.boot" includeLocation="true"/> |
| 69 | + <Logger level="warn" org.summerboot.jexpress.boot.instrumentation.Timeout includeLocation="true"/> |
| 70 | + <Logger level="info" name="org.summerboot.jexpress.integration.httpclient.HttpClientConfig" includeLocation="true"/> |
| 71 | + <Logger level="info" name="org.summerboot.jexpress.nio.server.NioServerHttpInitializer" includeLocation="true"/> |
| 72 | + <Logger level="debug" name="org.summerboot.jexpress.nio.server.NioServer" includeLocation="true"/> |
| 73 | + <Logger level="debug" name="org.summerboot.jexpress.nio.grpc.GRPCServer" includeLocation="true"/> |
19 | 74 |
|
20 |
| -/** |
21 |
| - * @author Changski Tie Zheng Zhang 张铁铮, 魏泽北, 杜旺财, 杜富贵 |
22 |
| - */ |
23 |
| -public interface BootConstant { |
24 | 75 |
|
25 |
| - String APP_ID = String.format("%06d", new Random().nextInt(999999)); |
| 76 | + <Logger level="warn" name="io.netty.handler" includeLocation="false" additivity="false"> |
| 77 | + <AppenderRef ref="RequestLogFile"/> |
| 78 | + <!-- --> |
| 79 | + <AppenderRef ref="Console"/> |
| 80 | + </Logger> |
26 | 81 |
|
27 |
| - //version |
28 |
| - String VERSION = "SummerBoot.jExpress 2.4.9"; |
29 |
| - String JEXPRESS_PACKAGE_NAME = "org.summerboot.jexpress"; |
| 82 | + <Logger level="info" name="org.summerboot.jexpress.nio.server.BootHttpRequestHandler" includeLocation="false" |
| 83 | + additivity="false"> |
| 84 | + <AppenderRef ref="RequestLogFile"/> |
| 85 | + <!-- --> |
| 86 | + <AppenderRef ref="Console"/> |
| 87 | + </Logger> |
| 88 | + <Logger level="info" name="org.summerboot.jexpress.integration.quartz.BootJobListener" includeLocation="false" |
| 89 | + additivity="false"> |
| 90 | + <AppenderRef ref="ScheduledLogFile"/> |
| 91 | + <!-- --> |
| 92 | + <AppenderRef ref="Console"/> |
| 93 | + </Logger> |
| 94 | + <Logger level="warn" name="org.summerboot.jexpress.integration.ldap" includeLocation="true" additivity="false"> |
| 95 | + <AppenderRef ref="RequestLogFile"/> |
| 96 | + <!-- --> |
| 97 | + <AppenderRef ref="Console"/> |
| 98 | + </Logger> |
| 99 | + <Logger level="debug" name="org.hibernate.SQL" includeLocation="true" additivity="false"> |
| 100 | + <AppenderRef ref="RequestLogFile"/> |
| 101 | + <!-- --> |
| 102 | + <AppenderRef ref="Console"/> |
| 103 | + </Logger> |
| 104 | + <Logger level="debug" name="org.hibernate.type" includeLocation="true" additivity="false"> |
| 105 | + <AppenderRef ref="RequestLogFile"/> |
| 106 | + <!-- --> |
| 107 | + <AppenderRef ref="Console"/> |
| 108 | + </Logger> |
30 | 109 |
|
31 |
| - String DEFAULT_ADMIN_MM = "changeit"; |
32 |
| - |
33 |
| - /* |
34 |
| - * Runtime info |
35 |
| - */ |
36 |
| - int CPU_CORE = Runtime.getRuntime().availableProcessors(); |
37 |
| - String PID = java.lang.management.ManagementFactory.getRuntimeMXBean().getName(); |
38 |
| - String BR = System.lineSeparator(); |
39 |
| - |
40 |
| - //logging metadata |
41 |
| - String LOG4J2_KEY = "log4j.configurationFile"; |
42 |
| - String LOG4J2_JDKADAPTER_KEY = "java.util.logging.manager"; |
43 |
| - String LOG4J2_JDKADAPTER_VALUE = "org.apache.logging.log4j.jul.LogManager"; |
44 |
| - |
45 |
| - /** |
46 |
| - * 3. jExpress Default Settings |
47 |
| - */ |
48 |
| - boolean CFG_ERROR_CODE_AS_INT = BackOffice.agent.isErrorCodeAsInt(); |
49 |
| - int CFG_CHANGE_MONITOR_INTERVAL_SEC = BackOffice.agent.getCfgChangeMonitorIntervalSec(); |
50 |
| - int PACKAGE_LEVEL = BackOffice.agent.getReflectionPackageLevel(); |
51 |
| - long WEB_RESOURCE_TTL_MS = BackOffice.agent.getWebResourceCacheTtlSec() * 1000; |
52 |
| - String DIR_STANDALONE = BackOffice.agent.getDomainFolderPrefix(); |
53 |
| - String DIR_CONFIGURATION = BackOffice.agent.getConfigFolderName(); |
54 |
| - String DIR_PLUGIN = BackOffice.agent.getPluginFolderName(); |
55 |
| - String DIR_LOG = BackOffice.agent.getLogFolderName(); |
56 |
| - |
57 |
| - String FILE_CFG_AUTH = BackOffice.agent.getAuthConfigFileName(); |
58 |
| - String FILE_CFG_SMTP = BackOffice.agent.getSmtpConfigFileName(); |
59 |
| - String FILE_CFG_NIO = BackOffice.agent.getNioConfigFileName(); |
60 |
| - String FILE_CFG_GRPC = BackOffice.agent.getgRPCConfigFileName(); |
61 |
| - |
62 |
| - /* |
63 |
| - * 4. jExpress Default CLI Name |
64 |
| - */ |
65 |
| - String CLI_USAGE = BackOffice.agent.getCliName_usage(); |
66 |
| - String CLI_VERSION = BackOffice.agent.getCliName_version(); |
67 |
| - String CLI_CONFIG_DOMAIN = BackOffice.agent.getCliName_domain(); |
68 |
| - String CLI_CONFIG_DIR = BackOffice.agent.getCliName_cfgdir(); |
69 |
| - String CLI_CONFIG_MONITOR_INTERVAL = BackOffice.agent.getCliName_monitorInterval(); |
70 |
| - String CLI_I8N = BackOffice.agent.getCliName_i18n(); |
71 |
| - String CLI_USE_IMPL = BackOffice.agent.getCliName_use();//To specify which implementation will be used via @Component.checkImplTagUsed |
72 |
| - String CLI_CONFIG_DEMO = BackOffice.agent.getCliName_cfgdemo(); |
73 |
| - String CLI_LIST_UNIQUE = BackOffice.agent.getCliName_list(); |
74 |
| - String CLI_ADMIN_PWD_FILE = BackOffice.agent.getCliName_authfile(); |
75 |
| - String CLI_ADMIN_PWD = BackOffice.agent.getCliName_auth(); |
76 |
| - String CLI_JWT = BackOffice.agent.getCliName_jwt(); |
77 |
| - String CLI_ENCRYPT = BackOffice.agent.getCliName_encrypt(); |
78 |
| - String CLI_DECRYPT = BackOffice.agent.getCliName_decrypt(); |
79 |
| - String MEMO_DELIMITER = BackOffice.agent.getMemoDelimiter(); |
80 |
| - |
81 |
| - /* |
82 |
| - * 5. Log4j2.xml variables |
83 |
| - * |
84 |
| - * Pass by System.setProperty() instead of making them public static, any better idea? |
85 |
| - * ‘java.lang.System.getProperty()’ API underlyingly uses ‘java.util.Hashtable.get()’ API. |
86 |
| - * Please be advised that ‘java.util.Hashtable.get()’ is a synchronized API. |
87 |
| - * It means only one thread can invoke the ‘java.util.Hashtable.get()’ method at any given time. |
88 |
| - */ |
89 |
| - String SYS_PROP_LOGID = BackOffice.agent.getLog4J2LogId();// "logid" // used by log4j2.xml ${sys:logid} |
90 |
| - String SYS_PROP_LOGFILEPATH = BackOffice.agent.getLog4j2LogFilePath();//"logPath"; // used by log4j2.xml ${sys:loggingPath} |
91 |
| - String SYS_PROP_LOGFILENAME = BackOffice.agent.getLog4j2LogFileName();//"appName"; // used by log4j2.xml ${sys:appappName} as log file name |
92 |
| - String SYS_PROP_SERVER_NAME = BackOffice.agent.getLog4j2ServerName();//"serverName"; // used by log4j2.xml ${hostName} |
93 |
| - String SYS_PROP_APP_PACKAGE_NAME = BackOffice.agent.getLog4j2AppPackageName();//"appPackageName"; // used by both log4j2.xml ${sys:appPackage} and JPAHibernateConfig to scan @Entity |
94 |
| - |
95 |
| -} |
| 110 | + <Logger level="debug" name="${sys:appPackageName}" includeLocation="true" additivity="false"> |
| 111 | + <AppenderRef ref="RequestLogFile"/> |
| 112 | + <!-- --> |
| 113 | + <AppenderRef ref="Console"/> |
| 114 | + </Logger> |
| 115 | + </Loggers> |
| 116 | +</Configuration> |
0 commit comments