-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature][Log] Integrate slf4j and log4j2 for unified management logs #3025
Conversation
appender.consoleWarn.filter.acceptGteWarn.type = ThresholdFilter | ||
appender.consoleWarn.filter.acceptGteWarn.level = WARN | ||
appender.consoleWarn.filter.acceptGteWarn.onMatch = ACCEPT | ||
appender.consoleWarn.filter.acceptGteWarn.onMismatch = DENY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public void handle(HttpGetCommand request) { | ||
String uri = request.getURI(); | ||
if (uri.startsWith(HttpCommandProcessor.URI_LOG_LEVEL)) { | ||
outputAllLoggerLevel(request); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public void handle(HttpPostCommand request) { | ||
String uri = request.getURI(); | ||
if (uri.startsWith(HttpCommandProcessor.URI_LOG_LEVEL)) { | ||
setLoggerLevel(request); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
03df195
to
6572476
Compare
config/log4j2-file.properties
Outdated
property.file_split_size = 100MB | ||
property.file_count = 100 | ||
property.file_ttl = 7d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log files:
max bytes = 100MB * 100
max times = 7d
</goals> | ||
<configuration> | ||
<includeGroupIds>org.slf4j,org.apache.logging.log4j</includeGroupIds> | ||
<outputDirectory>${project.build.directory}/logging-e2e</outputDirectory> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use by e2e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<configuration> | ||
<shadedArtifactAttached>false</shadedArtifactAttached> | ||
<createDependencyReducedPom>true</createDependencyReducedPom> | ||
<!-- Make sure the transitive dependencies are written to the generated pom under <dependencies> --> | ||
<promoteTransitiveDependencies>true</promoteTransitiveDependencies> | ||
<artifactSet> | ||
<excludes> | ||
<exclude>ch.qos.logback:*</exclude> | ||
</excludes> | ||
</artifactSet> | ||
</configuration> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
configuration from extends parent pom
<configuration> | ||
<artifactSet> | ||
<excludes> | ||
<!-- not excluded slf4j-api & log4j2 & bridges --> | ||
<exclude>org.slf4j:slf4j-jdk14</exclude> | ||
<exclude>org.slf4j:slf4j-nop</exclude> | ||
<exclude>org.slf4j:slf4j-simple</exclude> | ||
<exclude>org.slf4j:slf4j-reload4j</exclude> | ||
<exclude>org.slf4j:slf4j-log4j12</exclude> | ||
<exclude>log4j:*</exclude> | ||
<exclude>commons-logging:*</exclude> | ||
<exclude>ch.qos.logback:*</exclude> | ||
<!-- --> | ||
<exclude>org.apache.logging.log4j:log4j-to-slf4j</exclude> | ||
</excludes> | ||
</artifactSet> | ||
</configuration> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Override the parent's configuration
include: slf4j-api & log4j2
fi | ||
|
||
if [ -z $LOG4J2_CONTEXT_SELECTOR ]; then | ||
LOG4J2_CONTEXT_SELECTOR="org.apache.logging.log4j.core.async.AsyncLoggerContextSelector" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enable async logger
rest-api: | ||
enabled: true | ||
endpoint-groups: | ||
CLUSTER_WRITE: | ||
enabled: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enable API: POST /hazelcast/rest/log-level
372253f
to
918c1fc
Compare
</goals> | ||
<configuration> | ||
<includeGroupIds>org.slf4j,org.apache.logging.log4j</includeGroupIds> | ||
<outputDirectory>${project.build.directory}/logging-e2e</outputDirectory> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seatunnel-core/pom.xml
Outdated
<!-- not excluded: xxx-to-slf4j bridges, e.g. org.slf4j:jcl-over-slf4j --> | ||
<exclude>org.slf4j:slf4j-api</exclude> | ||
<exclude>org.slf4j:slf4j-jdk14</exclude> | ||
<exclude>org.slf4j:slf4j-nop</exclude> | ||
<exclude>org.slf4j:slf4j-simple</exclude> | ||
<exclude>org.slf4j:slf4j-reload4j</exclude> | ||
<exclude>org.slf4j:slf4j-log4j12</exclude> | ||
<exclude>ch.qos.logback:*</exclude> | ||
<exclude>log4j:*</exclude> | ||
<exclude>org.apache.logging.log4j:*</exclude> | ||
<exclude>commons-logging:*</exclude> | ||
</excludes> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
<!-- Declare log4j2 asynchronous loggers provider: disruptor --> | ||
<dependency> | ||
<groupId>com.lmax</groupId> | ||
<artifactId>disruptor</artifactId> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<finalName>${project.name}</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<configuration> | ||
<artifactSet> | ||
<excludes> | ||
<!-- not excluded: slf4j-api & log4j2 & xxx-to-slf4j bridges --> | ||
<exclude>org.slf4j:slf4j-jdk14</exclude> | ||
<exclude>org.slf4j:slf4j-nop</exclude> | ||
<exclude>org.slf4j:slf4j-simple</exclude> | ||
<exclude>org.slf4j:slf4j-reload4j</exclude> | ||
<exclude>org.slf4j:slf4j-log4j12</exclude> | ||
<exclude>log4j:*</exclude> | ||
<exclude>commons-logging:*</exclude> | ||
<exclude>ch.qos.logback:*</exclude> | ||
<exclude>org.apache.logging.log4j:log4j-to-slf4j</exclude> | ||
</excludes> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<includes> | ||
<include>org.slf4j:slf4j-api:jar</include> | ||
<include>org.slf4j:jcl-over-slf4j:jar</include> | ||
<include>org.apache.logging.log4j:log4j-api:jar</include> | ||
<include>org.apache.logging.log4j:log4j-core:jar</include> | ||
<include>org.apache.logging.log4j:log4j-slf4j-impl:jar</include> | ||
</includes> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MountableFile.forHostPath(loggingLibPath), | ||
Paths.get(seatunnelHomeInContainer, "lib", "logging").toString()); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix CI problem. |
9617b2e
to
4dec94e
Compare
property.file_split_size = 100MB | ||
property.file_count = 100 | ||
property.file_ttl = 7d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log files:
max bytes = 100MB * 100
max times = 7d
rootLogger.appenderRef.consoleWarn.ref = consoleWarn | ||
################################# console log ################################# | ||
################################# file log ################################# | ||
#rootLogger.appenderRef.file.ref = fileAppender |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disable file log
JAVA_OPTS="${JAVA_OPTS} -Dlog4j2.configurationFile=${CONF_DIR}/log4j2.properties" | ||
JAVA_OPTS="${JAVA_OPTS} -Dseatunnel.logs.path=${APP_DIR}/logs" | ||
JAVA_OPTS="${JAVA_OPTS} -Dseatunnel.logs.file_name=seatunnel-core-flink-sql" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add log4j2 system properties
JAVA_OPTS="${JAVA_OPTS} -Dseatunnel.logs.file_name=seatunnel-core-flink-sql" | ||
fi | ||
|
||
CLASS_PATH=${APP_DIR}/lib/logging/*:${APP_JAR} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add lib/logging/
into starter jar classpath
echo "Execute SeaTunnel Flink SQL Job: $(echo "${CMD}" | tail -n 1)" | ||
eval $(echo "${CMD}" | tail -n 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tail last line text
echo "Execute SeaTunnel Spark Job: $(echo "${CMD}" | tail -n 1)" | ||
eval $(echo "${CMD}" | tail -n 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix tail last line text: ${CMD} -> "${CMD}"
2189cf0
to
e253812
Compare
@TyrantLucifer @EricJoy2048 @ashulin @Hisoka-X @CalvinKirs thx. PTAL |
close #2474 |
resolve conflicts please. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CalvinKirs CC, Does he need to resolve license conflicts?
e253812
to
60082ad
Compare
b1eee12
to
ad9b5ea
Compare
60afeb2
to
15b890d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d538c63
to
a57c9b2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Maven dependencys: - Add slf4j & log4j2 provider & bridges scope into root pom.xml dependencyManagement - include: slf4j-api、log4j2、log4j2-slf4j-impl(slf4j provider)、xxx-to-slf4j - exclude(provided): logback、log4j1、commons-logging、slf4j-other-provider、log4j2-to-slf4j - Add slf4j & log4j2 & jcl-over-slf4j into root pom.xml dependencies - Exclude all logging system packages in maven-sheade-plugin SeaTunnel engine module: - Enhanced logging http endpoint to dynamically change log4j2 level - Config `hazelcast.logging.type: log4j2` SeaTunnel Dist module: - Use `maven-assembly-plugin` to copy slf4j & log4j2 & jcl-over-slf4j packages to `lib/logging` for use by starter shell Engine Starter module[flink]: - Use `maven-dependency-plugin` to copy slf4j & log4j2 & jcl-over-slf4j packages to `target/logging-e2e` for use by E2E testcase - Add `lib/logging` directory to java classpath in start shell for use by starter class - Add jcl-over-slf4j package into shade jar - Config `config/log4j2-console.properties` on engine-client - Exclude log4j1 & log4j2 & logback & commons-logging from shade jar - Fix shell script tail last line text Engine Starter module[spark]: - Use `maven-dependency-plugin` to copy slf4j & log4j2 & jcl-over-slf4j packages to `target/logging-e2e` for use by E2E testcase - Add `lib/logging` directory to java classpath in start shell for use by starter class - Config `config/log4j2-console.properties` on engine-client - Exclude log4j1 & log4j2 & logback & commons-logging from shade jar - Fix shell script tail last line text Engine Starter module[seatunnel]: - Add `disruptor` jar and config `-Dlog4j2.contextSelector` to use asynchronous logger on engine-server - Config `config/log4j2-file.properties` on engine-server - Config `config/log4j2-console.properties` on engine-client - Add slf4j & log4j2 & jcl-over-slf4j & log4j-1.2-api package into starter shade jar Connector-v1 module[seatunnel-connector-flink-clickhouse]: - Exclude commons-logging from shade jar E2E: - Remove `log4j.properties` files - Add `log4j2-test.properties` output log to `STDOUT` or `STDERR` - Copy starter[flink、spark] `target/logging-e2e` into engine container - Copy config dir into engine container - Improve execute job logs
a57c9b2
to
35b8222
Compare
Purpose of this pull request
proposal #2725
Change logs:
Maven dependencys:
SeaTunnel engine module:
hazelcast.logging.type: log4j2
SeaTunnel Dist module:
maven-assembly-plugin
to copy slf4j & log4j2 & jcl-over-slf4j packages tolib/logging
for use by starter shellEngine Starter module[flink、spark]:
maven-dependency-plugin
to copy slf4j & log4j2 & jcl-over-slf4j packages totarget/logging-e2e
for use by E2E testcaselib/logging
directory to java classpath in start shell for use by starter classconfig/log4j2-console.properties
on engine-clientEngine Starter module[seatunnel]:
disruptor
jar and config-Dlog4j2.contextSelector
to use asynchronous logger on engine-serverconfig/log4j2-file.properties
on engine-serverconfig/log4j2-console.properties
on engine-clientConnector-v1 module[seatunnel-connector-flink-clickhouse]:
E2E:
log4j.properties
fileslog4j2-test.properties
output log toSTDOUT
orSTDERR
target/logging-e2e
into engine containerCheck list
New License Guide