asl3 opened a new pull request, #47655:
URL: https://github.com/apache/spark/pull/47655

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: 
https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: 
https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., 
'[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a 
faster review.
     7. If you want to add a new configuration, please read the guideline first 
for naming configurations in
        
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the 
guideline first in
        'common/utils/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   
   This issue updates the default `log4j.properties.template` with the 
following improvements for console logging format:
   
   - Use PatternLayout for improved human readability
   - Color-code log levels to simplify logging output
   - Visually partition the threadName and contextInfo for easy interpretation
   
   See below for sample screenshots of the improved logs.
   
   ### Why are the changes needed?
   Prior to this update, the OSS Spark logs were difficult to interpret. The 
logs followed a JSON output format which is not optimal for human consumption:
   
   ```
   {"ts":"2024-07-26T18:45:17.712Z","level":"INFO","msg":"Running Spark version 
4.0.0-SNAPSHOT","context":{"spark_version":"4.0.0-SNAPSHOT"},"logger":"SparkContext"}{"ts":"2024-07-26T18:45:17.715Z","level":"INFO","msg":"OS
 info Mac OS X, 14.4.1, aarch64","context":{"os_arch":"aarch64","os_name":"Mac 
OS 
X","os_version":"14.4.1"},"logger":"SparkContext"}{"ts":"2024-07-26T18:45:17.716Z","level":"INFO","msg":"Java
 version 
17.0.11","context":{"java_version":"17.0.11"},"logger":"SparkContext"}{"ts":"2024-07-26T18:45:17.761Z","level":"WARN","msg":"Unable
 to load native-hadoop library for your platform... using builtin-java classes 
where 
applicable","logger":"NativeCodeLoader"}{"ts":"2024-07-26T18:45:17.783Z","level":"INFO","msg":"==============================================================","logger":"ResourceUtils"}{"ts":"2024-07-26T18:45:17.783Z","level":"INFO","msg":"No
 custom resources configured for 
spark.driver.","logger":"ResourceUtils"}{"ts":"2024-07-26T18:45:17.783Z","level":"INFO
 
","msg":"==============================================================","logger":"ResourceUtils"}{"ts":"2024-07-26T18:45:17.784Z","level":"INFO","msg":"Submitted
 application: Spark Pi","context":{"app_name":"Spark 
Pi"},"logger":"SparkContext"}...{"ts":"2024-07-26T18:45:18.036Z","level":"INFO","msg":"Start
 Jetty 0.0.0.0:4040 for 
SparkUI","context":{"host":"0.0.0.0","port":"4040","server_name":"SparkUI"},"logger":"JettyUtils"}{"ts":"2024-07-26T18:45:18.044Z","level":"INFO","msg":"jetty-11.0.20;
 built: 2024-01-29T21:04:22.394Z; git: 
922f8dc188f7011e60d0361de585fd4ac4d63064; jvm 
17.0.11+9-LTS","logger":"Server"}{"ts":"2024-07-26T18:45:18.054Z","level":"INFO","msg":"Started
 Server@22c75c01{STARTING}[11.0.20,sto=30000] @1114ms","logger":"Server"} 
   ```
   
   ### Does this PR introduce _any_ user-facing change?
   Yes, please see below for the updated log output. Note that users can 
override the provided `log4j.properties.template` as desired.
   
   <img width="1403" alt="Screenshot 2024-08-07 at 10 38 25 AM" 
src="https://github.com/user-attachments/assets/7d5330f1-33b7-4957-88df-18f16fafe099";>
   
   <img width="1404" alt="Screenshot 2024-08-07 at 10 38 55 AM" 
src="https://github.com/user-attachments/assets/a389c0a0-91b3-45cf-951b-496e5e4a5908";>
   
   ### How was this patch tested?
   Producing console logs via spark-submit, e.g:
   
   `./bin/spark-submit --class org.apache.spark.examples.SparkPi  
examples/target/scala-2.13/jars/spark-examples_2.13-4.0.0-SNAPSHOT.jar 100`
   
   ### Was this patch authored or co-authored using generative AI tooling?
   No
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to