<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=Spark_event_log</id>
	<title>Spark event log - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=Spark_event_log"/>
	<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Spark_event_log&amp;action=history"/>
	<updated>2026-12-06T00:29:52Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://openlakehouse.io/w/index.php?title=Spark_event_log&amp;diff=186&amp;oldid=prev</id>
		<title>Open Lakehouse Wiki sync: Sync from open-lakehouse/wiki@7c9abaa</title>
		<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Spark_event_log&amp;diff=186&amp;oldid=prev"/>
		<updated>2026-11-25T00:52:53Z</updated>

		<summary type="html">&lt;p&gt;Sync from open-lakehouse/wiki@7c9abaa&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Infobox concept&lt;br /&gt;
| name            = Spark event log&lt;br /&gt;
| also_known_as   = Event log, eventLog&lt;br /&gt;
| field           = Monitoring and debugging&lt;br /&gt;
| key_parts       = EventLoggingListener, JSON lines (one listener event per line), compression codec, rolling files, compaction&lt;br /&gt;
| implementations = [[Apache Spark]]&lt;br /&gt;
| related         = [[Spark History Server]], [[Spark UI]], [[Spark listener]]&lt;br /&gt;
}}&lt;br /&gt;
{{Verified|2026-11-23|the v4.3.0 tag of apache/spark (EventLoggingListener.scala, EventLogFileWriters.scala, config/package.scala, config/History.scala, docs/configuration.md, docs/monitoring.md, docs/core-migration-guide.md) and Spark JIRA SPARK-28594 and SPARK-45771}}&lt;br /&gt;
&lt;br /&gt;
The &amp;#039;&amp;#039;&amp;#039;Spark event log&amp;#039;&amp;#039;&amp;#039; is a file, or a directory of files, in which an [[Apache Spark]] application records the listener events that its driver posts for jobs, stages, tasks, executors and SQL query executions, so that the application&amp;#039;s [[Spark UI]] can be rebuilt after it ends. Not every event is written: some are recorded only when a setting turns them on, events can opt out of logging, and &amp;lt;code&amp;gt;spark.eventLog.excludedPatterns&amp;lt;/code&amp;gt; suppresses named events.&amp;lt;ref name=&amp;quot;ell&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/core/src/main/scala/org/apache/spark/scheduler/EventLoggingListener.scala |title=EventLoggingListener.scala (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; The [[Spark History Server]] reads event logs to show finished applications. Event logging is off by default and is turned on with &amp;lt;code&amp;gt;spark.eventLog.enabled&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;coreconf&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/core/src/main/scala/org/apache/spark/internal/config/package.scala |title=config/package.scala (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== What does the event log record? ==&lt;br /&gt;
The event log is written by &amp;lt;code&amp;gt;EventLoggingListener&amp;lt;/code&amp;gt;, a [[Spark listener]] that the driver registers when event logging is on. Each event that it logs is serialized to JSON and written as one line; the first line records the Spark version.&amp;lt;ref name=&amp;quot;ell&amp;quot; /&amp;gt; The events include application start and end, job start and end, stage submission and completion, task start and end with task metrics, executors added and removed, environment updates, and SQL execution start and end with the query plans. These are the kinds of events that also build the live Spark UI.&lt;br /&gt;
&lt;br /&gt;
Some events are left out by default. &amp;lt;code&amp;gt;EventLoggingListener&amp;lt;/code&amp;gt; writes block updates and stage executor metrics only when their settings are on, writes events from other modules only if the event&amp;#039;s &amp;lt;code&amp;gt;logEvent&amp;lt;/code&amp;gt; flag is true, and the log writer drops any line that starts with a pattern listed in &amp;lt;code&amp;gt;spark.eventLog.excludedPatterns&amp;lt;/code&amp;gt;:&amp;lt;ref name=&amp;quot;ell&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;writers&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;coreconf&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;confdoc&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/configuration.html |title=Spark Configuration (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;spark.eventLog.logBlockUpdates.enabled&amp;lt;/code&amp;gt; (default false) logs every block update. The documentation warns that this increases the size of the event log considerably.&lt;br /&gt;
* &amp;lt;code&amp;gt;spark.eventLog.logStageExecutorMetrics&amp;lt;/code&amp;gt; (default false) writes per-stage peaks of executor metrics.&lt;br /&gt;
&lt;br /&gt;
== Where is the event log written? ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
spark.eventLog.enabled  true&lt;br /&gt;
spark.eventLog.dir      hdfs://namenode/shared/spark-logs&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;spark.eventLog.dir&amp;lt;/code&amp;gt; defaults to &amp;lt;code&amp;gt;/tmp/spark-events&amp;lt;/code&amp;gt;, a path on the driver&amp;#039;s local file system, so on a cluster it is set to a shared location such as HDFS or object storage that the [[Spark History Server]] also reads.&amp;lt;ref name=&amp;quot;coreconf&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;ell&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;monitoring&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/monitoring.html |title=Monitoring and Instrumentation (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A single-file event log is named after the application ID and carries an &amp;lt;code&amp;gt;.inprogress&amp;lt;/code&amp;gt; suffix until the application ends. A rolling event log is a directory named &amp;lt;code&amp;gt;eventlog_v2_&amp;amp;lt;appId&amp;amp;gt;&amp;lt;/code&amp;gt; that holds numbered &amp;lt;code&amp;gt;events_&amp;amp;lt;index&amp;amp;gt;_&amp;amp;lt;appId&amp;amp;gt;&amp;lt;/code&amp;gt; files and an &amp;lt;code&amp;gt;appstatus_&amp;amp;lt;appId&amp;amp;gt;&amp;lt;/code&amp;gt; file, which also has the &amp;lt;code&amp;gt;.inprogress&amp;lt;/code&amp;gt; suffix while the application runs.&amp;lt;ref name=&amp;quot;writers&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/core/src/main/scala/org/apache/spark/deploy/history/EventLogFileWriters.scala |title=EventLogFileWriters.scala (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== What changed in Spark 4.0? ==&lt;br /&gt;
Two event log defaults changed in Spark 4.0. The Spark migration guide says that since 4.0, Spark rolls event logs to archive them incrementally, and that it compresses event logs; setting &amp;lt;code&amp;gt;spark.eventLog.rolling.enabled&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;spark.eventLog.compress&amp;lt;/code&amp;gt; to false restores the earlier behaviour.&amp;lt;ref name=&amp;quot;migration&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/core-migration-guide.html |title=Migration Guide: Spark Core (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; The rolling default came from SPARK-45771.&amp;lt;ref&amp;gt;{{Cite web |url=https://issues.apache.org/jira/browse/SPARK-45771 |title=SPARK-45771: Enable spark.eventLog.rolling.enabled by default |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; Since Spark 3.2, the event log codec defaults to &amp;lt;code&amp;gt;zstd&amp;lt;/code&amp;gt; and no longer falls back to &amp;lt;code&amp;gt;spark.io.compression.codec&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;migration&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Setting !! Default in 4.3.0 !! Since&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.eventLog.enabled&amp;lt;/code&amp;gt; || false || 1.0.0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.eventLog.dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;/tmp/spark-events&amp;lt;/code&amp;gt; || 1.0.0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.eventLog.compress&amp;lt;/code&amp;gt; || true || 1.0.0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.eventLog.compression.codec&amp;lt;/code&amp;gt; || zstd || 3.0.0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.eventLog.rolling.enabled&amp;lt;/code&amp;gt; || true || 3.0.0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.eventLog.rolling.maxFileSize&amp;lt;/code&amp;gt; || 128m || 3.0.0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.eventLog.excludedPatterns&amp;lt;/code&amp;gt; || (none) || 4.1.0&lt;br /&gt;
|}&lt;br /&gt;
All values are from the Spark 4.3.0 source.&amp;lt;ref name=&amp;quot;coreconf&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Why do event logs get so large? ==&lt;br /&gt;
An event log grows with the number of tasks, because every task end event carries the task&amp;#039;s metrics. Applications with many small tasks, long-running [[Structured Streaming]] queries that run a job for every micro-batch, and queries with very large plans produce the largest logs. A large single-file log is slow for the History Server to replay, because the whole file must be read to build the UI.&amp;lt;ref name=&amp;quot;monitoring&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ways to keep event logs manageable:&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Rolling.&amp;#039;&amp;#039;&amp;#039; With &amp;lt;code&amp;gt;spark.eventLog.rolling.enabled&amp;lt;/code&amp;gt; (on by default since 4.0), Spark starts a new file when the current one reaches &amp;lt;code&amp;gt;spark.eventLog.rolling.maxFileSize&amp;lt;/code&amp;gt; (default 128m). Rolling was added for running streaming applications in Spark 3.0.0 (SPARK-28594).&amp;lt;ref name=&amp;quot;coreconf&amp;quot; /&amp;gt;&amp;lt;ref&amp;gt;{{Cite web |url=https://issues.apache.org/jira/browse/SPARK-28594 |title=SPARK-28594: Allow event logs for running streaming apps to be rolled over |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Compaction.&amp;#039;&amp;#039;&amp;#039; Rolling alone does not reduce the total size. Setting &amp;lt;code&amp;gt;spark.history.fs.eventLog.rolling.maxFilesToRetain&amp;lt;/code&amp;gt; on the History Server compacts older rolled files and drops events for finished jobs, terminated executors and finished SQL executions. The documentation describes compaction as lossy.&amp;lt;ref name=&amp;quot;monitoring&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;history&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/core/src/main/scala/org/apache/spark/internal/config/History.scala |title=config/History.scala (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Excluding events.&amp;#039;&amp;#039;&amp;#039; &amp;lt;code&amp;gt;spark.eventLog.excludedPatterns&amp;lt;/code&amp;gt; (since 4.1.0) takes a comma-separated list of event names that are not written.&amp;lt;ref name=&amp;quot;confdoc&amp;quot; /&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Leaving verbose events off&amp;#039;&amp;#039;&amp;#039;, such as block updates.&amp;lt;ref name=&amp;quot;confdoc&amp;quot; /&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Retention.&amp;#039;&amp;#039;&amp;#039; The History Server cleaner (&amp;lt;code&amp;gt;spark.history.fs.cleaner.enabled&amp;lt;/code&amp;gt;, default false) deletes old logs.&amp;lt;ref name=&amp;quot;history&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reading an event log without the History Server ==&lt;br /&gt;
Because each line is a JSON object whose &amp;lt;code&amp;gt;Event&amp;lt;/code&amp;gt; field names the event class (for example &amp;lt;code&amp;gt;SparkListenerStageCompleted&amp;lt;/code&amp;gt;),&amp;lt;ref name=&amp;quot;jsonprotocol&amp;quot; /&amp;gt; a compressed log can be decompressed and read with ordinary JSON tools. Spark itself can read one as a JSON data source, which is a quick way to find the slowest stages of a finished run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
events = spark.read.json(&amp;quot;/tmp/spark-events/app-20261123120000-0000&amp;quot;)&lt;br /&gt;
(events.filter(&amp;quot;Event = &amp;#039;SparkListenerStageCompleted&amp;#039;&amp;quot;)&lt;br /&gt;
       .selectExpr(&amp;quot;`Stage Info`.`Stage ID` AS stage&amp;quot;,&lt;br /&gt;
                   &amp;quot;`Stage Info`.`Completion Time` - `Stage Info`.`Submission Time` AS ms&amp;quot;)&lt;br /&gt;
       .orderBy(&amp;quot;ms&amp;quot;, ascending=False)&lt;br /&gt;
       .show(5))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The JSON format comes from Spark&amp;#039;s &amp;lt;code&amp;gt;JsonProtocol&amp;lt;/code&amp;gt;, an internal class whose source states that any version of Spark should be able to read event logs written by any other version, and that JSON fields are never deleted, only added as optional fields.&amp;lt;ref name=&amp;quot;jsonprotocol&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/core/src/main/scala/org/apache/spark/util/JsonProtocol.scala |title=JsonProtocol.scala (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; For tools, the REST API of the History Server or the live UI, at &amp;lt;code&amp;gt;/api/v1&amp;lt;/code&amp;gt;, is the documented interface to the same data and has its own versioning policy.&amp;lt;ref name=&amp;quot;monitoring&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Spark History Server]]&lt;br /&gt;
* [[Spark UI]]&lt;br /&gt;
* [[Spark listener]]&lt;br /&gt;
* [[Structured Streaming]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Navbox open lakehouse}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Concepts]]&lt;br /&gt;
[[Category:Glossary terms]]&lt;br /&gt;
[[Category:Apache Spark]]&lt;/div&gt;</summary>
		<author><name>Open Lakehouse Wiki sync</name></author>
	</entry>
</feed>