Skip to content

[fix](jni) fix JNI logging by migrating to log4j2 with proper configuration#60584

Open
morningman wants to merge 4 commits intoapache:masterfrom
morningman:fix-jni
Open

[fix](jni) fix JNI logging by migrating to log4j2 with proper configuration#60584
morningman wants to merge 4 commits intoapache:masterfrom
morningman:fix-jni

Conversation

@morningman
Copy link
Contributor

@morningman morningman commented Feb 6, 2026

The BE's jni.log was not being written to because the JNI scanner module
was using log4j 1.x APIs which were not properly configured in the JNI
classloader environment.

Changes:

  • Migrate ScannerLoader from log4j 1.x to log4j2 API
  • Add log4j2.xml configuration with RollingFile appender for jni.log
  • Initialize log4j2 explicitly in ScannerLoader's static block to ensure
    logging works in JNI environment
  • Trigger log4j2 initialization from TrinoConnectorPluginLoader before
    plugin loading
  • Improve error messages in TrinoConnectorCache by including root cause
    via ExceptionUtils.getRootCauseMessage()
  • Preserve original exception as cause in invalidateTableCache()
  • Use parameterized logging consistently instead of string concatenation
  • Remove unused Log4jOutputStream class and no-op redirectStdStreamsToLog4j()

@hello-stephen
Copy link
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@morningman morningman changed the title [fix](jni) fix issue that BE's jni.log doesn't work [fix](jni) fix JNI logging by migrating to log4j2 with proper configuration Feb 6, 2026
@morningman
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

TPC-H: Total hot run time: 30491 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 4a3f6f59f2f684be473df3ac2a367daeade66a86, data reload: false

------ Round 1 ----------------------------------
q1	17602	4457	4320	4320
q2	2023	335	225	225
q3	10177	1283	706	706
q4	10197	764	324	324
q5	7524	2141	1906	1906
q6	201	172	147	147
q7	906	720	613	613
q8	9269	1343	1144	1144
q9	4647	4591	4538	4538
q10	6828	1914	1552	1552
q11	524	305	292	292
q12	337	371	227	227
q13	17787	4002	3236	3236
q14	235	234	215	215
q15	892	793	806	793
q16	665	675	621	621
q17	685	756	574	574
q18	6457	5745	5848	5745
q19	2041	1042	654	654
q20	560	559	445	445
q21	2702	2104	1909	1909
q22	367	327	305	305
Total cold run time: 102626 ms
Total hot run time: 30491 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4648	4607	4674	4607
q2	271	343	268	268
q3	2227	2961	2512	2512
q4	1518	1834	1392	1392
q5	4548	4701	4657	4657
q6	224	184	140	140
q7	1908	1886	1764	1764
q8	2633	2520	2423	2423
q9	7633	7565	7586	7565
q10	2936	3152	2632	2632
q11	551	477	447	447
q12	690	774	605	605
q13	3890	4130	3316	3316
q14	276	300	277	277
q15	832	790	786	786
q16	642	678	641	641
q17	1061	1200	1227	1200
q18	7465	7361	7377	7361
q19	831	788	795	788
q20	1945	2021	1877	1877
q21	4469	4202	4086	4086
q22	570	546	521	521
Total cold run time: 51768 ms
Total hot run time: 49865 ms

@doris-robot
Copy link

ClickBench: Total hot run time: 28.14 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 4a3f6f59f2f684be473df3ac2a367daeade66a86, data reload: false

query1	0.05	0.05	0.05
query2	0.09	0.05	0.05
query3	0.26	0.09	0.08
query4	1.60	0.11	0.11
query5	0.27	0.25	0.25
query6	1.16	0.68	0.66
query7	0.03	0.03	0.02
query8	0.05	0.03	0.04
query9	0.56	0.50	0.51
query10	0.55	0.54	0.54
query11	0.15	0.09	0.09
query12	0.13	0.10	0.11
query13	0.62	0.61	0.62
query14	1.05	1.06	1.04
query15	0.87	0.86	0.87
query16	0.38	0.39	0.42
query17	1.15	1.16	1.11
query18	0.22	0.21	0.21
query19	2.04	2.01	2.05
query20	0.02	0.01	0.01
query21	15.43	0.27	0.14
query22	5.29	0.06	0.05
query23	16.20	0.30	0.10
query24	1.33	0.24	0.18
query25	0.12	0.06	0.06
query26	0.15	0.14	0.12
query27	0.08	0.06	0.05
query28	3.70	1.15	0.97
query29	12.64	3.90	3.16
query30	0.28	0.13	0.12
query31	2.81	0.64	0.40
query32	3.25	0.58	0.51
query33	3.19	3.23	3.25
query34	16.40	5.38	4.72
query35	4.78	4.74	4.83
query36	0.64	0.50	0.49
query37	0.11	0.07	0.07
query38	0.07	0.04	0.04
query39	0.04	0.03	0.03
query40	0.20	0.16	0.15
query41	0.08	0.03	0.03
query42	0.05	0.03	0.03
query43	0.04	0.04	0.03
Total cold run time: 98.13 s
Total hot run time: 28.14 s

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

Increment line coverage `` 🎉
Increment coverage report
Complete coverage report

Copy link
Contributor

@kaka11chen kaka11chen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Feb 7, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2026

PR approved by at least one committer and no changes requested.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2026

PR approved by anyone and no changes requested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. dev/3.1.x dev/4.0.x reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants