|
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> |
| 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; |
14 | 17 |
|
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"/> |
| 18 | +import java.util.Random; |
74 | 19 |
|
| 20 | +/** |
| 21 | + * @author Changski Tie Zheng Zhang 张铁铮, 魏泽北, 杜旺财, 杜富贵 |
| 22 | + */ |
| 23 | +public interface BootConstant { |
75 | 24 |
|
76 |
| - <Logger level="warn" name="io.netty.handler" includeLocation="false" additivity="false"> |
77 |
| - <AppenderRef ref="RequestLogFile"/> |
78 |
| - <!-- --> |
79 |
| - <AppenderRef ref="Console"/> |
80 |
| - </Logger> |
| 25 | + String APP_ID = String.format("%06d", new Random().nextInt(999999)); |
81 | 26 |
|
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> |
| 27 | + //version |
| 28 | + String VERSION = "SummerBoot.jExpress 2.4.10"; |
| 29 | + String JEXPRESS_PACKAGE_NAME = "org.summerboot.jexpress"; |
109 | 30 |
|
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> |
| 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 | + String RESPONSE_HEADER_KEY_REF = "X-Reference"; |
| 63 | + String RESPONSE_HEADER_KEY_TS = "X-ServerTs"; |
| 64 | + |
| 65 | + String PAUSE_LOCK_CODE_VIAFILE = BackOffice.agent.getPauseLockCodeViaFile(); |
| 66 | + String PAUSE_LOCK_CODE_VIAWEB = BackOffice.agent.getPauseLockCodeViaWeb(); |
| 67 | + |
| 68 | + |
| 69 | + /* |
| 70 | + * 4. jExpress Default CLI Name |
| 71 | + */ |
| 72 | + String CLI_USAGE = BackOffice.agent.getCliName_usage(); |
| 73 | + String CLI_VERSION = BackOffice.agent.getCliName_version(); |
| 74 | + String CLI_CONFIG_DOMAIN = BackOffice.agent.getCliName_domain(); |
| 75 | + String CLI_CONFIG_DIR = BackOffice.agent.getCliName_cfgdir(); |
| 76 | + String CLI_CONFIG_MONITOR_INTERVAL = BackOffice.agent.getCliName_monitorInterval(); |
| 77 | + String CLI_I8N = BackOffice.agent.getCliName_i18n(); |
| 78 | + String CLI_USE_IMPL = BackOffice.agent.getCliName_use();//To specify which implementation will be used via @Component.checkImplTagUsed |
| 79 | + String CLI_CONFIG_DEMO = BackOffice.agent.getCliName_cfgdemo(); |
| 80 | + String CLI_LIST_UNIQUE = BackOffice.agent.getCliName_list(); |
| 81 | + String CLI_ADMIN_PWD_FILE = BackOffice.agent.getCliName_authfile(); |
| 82 | + String CLI_ADMIN_PWD = BackOffice.agent.getCliName_auth(); |
| 83 | + String CLI_JWT = BackOffice.agent.getCliName_jwt(); |
| 84 | + String CLI_ENCRYPT = BackOffice.agent.getCliName_encrypt(); |
| 85 | + String CLI_DECRYPT = BackOffice.agent.getCliName_decrypt(); |
| 86 | + String CLI_PSV = BackOffice.agent.getCliName_psv(); |
| 87 | + String MEMO_DELIMITER = BackOffice.agent.getMemoDelimiter(); |
| 88 | + |
| 89 | + /* |
| 90 | + * 5. Log4j2.xml variables |
| 91 | + * |
| 92 | + * Pass by System.setProperty() instead of making them public static, any better idea? |
| 93 | + * ‘java.lang.System.getProperty()’ API underlyingly uses ‘java.util.Hashtable.get()’ API. |
| 94 | + * Please be advised that ‘java.util.Hashtable.get()’ is a synchronized API. |
| 95 | + * It means only one thread can invoke the ‘java.util.Hashtable.get()’ method at any given time. |
| 96 | + */ |
| 97 | + String SYS_PROP_LOGID = BackOffice.agent.getLog4J2LogId();// "logid" // used by log4j2.xml ${sys:logid} |
| 98 | + String SYS_PROP_LOGFILEPATH = BackOffice.agent.getLog4j2LogFilePath();//"logPath"; // used by log4j2.xml ${sys:loggingPath} |
| 99 | + String SYS_PROP_LOGFILENAME = BackOffice.agent.getLog4j2LogFileName();//"appName"; // used by log4j2.xml ${sys:appappName} as log file name |
| 100 | + String SYS_PROP_SERVER_NAME = BackOffice.agent.getLog4j2ServerName();//"serverName"; // used by log4j2.xml ${hostName} |
| 101 | + String SYS_PROP_APP_PACKAGE_NAME = BackOffice.agent.getLog4j2AppPackageName();//"appPackageName"; // used by both log4j2.xml ${sys:appPackage} and JPAHibernateConfig to scan @Entity |
| 102 | + |
| 103 | +} |
0 commit comments