.LDF

LDF File

Microsoft SQL Server Transaction Log File
Ask a question
QUICK ANSWER

An LDF file is the transaction log of a Microsoft SQL Server database. It records every change so the database can recover after a crash or roll back a failed transaction. You do not open it directly - attach or restore the database in SQL Server Management Studio, which handles both the .mdf data file and the .ldf log file together.

Developer: Microsoft Category: Database Files MIME: application/octet-stream
OPENS ON Windows Linux
Related: .DB · .DBF · .ACCDB · .SQL

On this page

19k+ extensions indexed
Last reviewed Jul 24, 2026

Not sure what your file is?

Drop any file into our identifier - we read just the first bytes to name the format.

Identify a file

What is the LDF file format?

An .ldf file is a Transaction Log File created by Microsoft SQL Server to record every change made to a database before those changes are written to disk. It implements a write-ahead logging strategy: SQL Server writes a log record first, then applies the corresponding change to data pages.

Every .ldf works as the paired companion to a primary .mdf data file. Without a healthy log file the database cannot come online; deleting or losing an .ldf outside of controlled procedures can make a database unrecoverable.

Internally the log is divided into Virtual Log Files (VLFs) - fixed segments that SQL Server allocates and reuses in a circular fashion. Each log record carries a unique Log Sequence Number (LSN), a 10-byte value encoding the file number, block offset, and slot within a 512-byte log block. The LSN chain is what the engine follows during crash recovery to redo committed transactions and undo incomplete ones.

The .ldf underpins several critical SQL Server features:

  • Crash recovery - replaying or rolling back in-flight transactions after an unexpected shutdown
  • Point-in-time restore - used together with a .bak full backup and .trn log backups under the FULL recovery model
  • Replication and Change Data Capture (CDC) - reading committed changes directly from the log

The format is proprietary binary with no publicly documented magic bytes and cannot be opened by hand. Third-party tools such as ApexSQL Log or Redgate SQL Log can decode log records for auditing or forensic purposes. From SQL Server 2017 onward, .ldf files are supported identically on Linux and in Docker containers alongside the .ndf secondary data files.

Security & safety

RISK: MEDIUM

The file is data, not executable, so it carries no direct malware risk. The real danger is operational: deleting or detaching an .ldf from a live or "suspect" database can cause data loss or make the database unrecoverable, and creating a database without its log (or with a rebuilt log) loses in-flight transactions. Never hand-edit an .ldf. If the log is huge, shrink it the supported way (back up the log, then DBCC SHRINKFILE) rather than deleting it. TDE-encrypted logs require the database's certificate/keys to restore.

Format details

in a nutshell
FULL NAMEMicrosoft SQL Server Transaction Log Fileaka SQL Server log file, Log Data File
DEVELOPERMicrosoftsince Microsoft SQL Server (log architecture present since the Sybase-derived 4.x/6.x era, 1990s)
MIME TYPEapplication/octet-stream
TYPEProprietary binary write-ahead transaction log, paired with an .mdf data file

Programs that open LDF files

Windows3 apps
SQL Server Management Studio (SSMS) Free Attach or restore the database (which references both .mdf and .ldf); use DBCC SQLPERF(LOGSPACE) to inspect log usage. You do not open the .ldf file directly.
Azure Data Studio Open-source Cross-platform client to connect to the SQL Server instance and manage/restore the database that owns the log.
ApexSQL Log / Redgate SQL Log (forensic log readers) Paid Specialist read-only auditing tools that decode past transactions from the .ldf/backups for recovery - not general viewers.
Linux1 app
SQL Server on Linux + sqlcmd / Azure Data Studio Free Run the SQL Server engine on Linux and restore/attach the database; manage the log through T-SQL.

Technical details

deep spec
EncodingBinary, little-endian
Container structureSequence of Virtual Log Files (VLFs); SQL Server allocates and reuses VLFs in a circular pattern as log space is freed
Log record unitVariable-length log records packed into 512-byte log blocks
Record identifierLog Sequence Number (LSN) - a 10-byte value encoding the log file number, block offset within the file, and slot number within the block
Circular reuseLog space is reclaimed and reused once the active portion is no longer needed - after a checkpoint in SIMPLE model or a log backup in FULL model
Recovery model supportBehavior differs per SQL Server recovery model: SIMPLE (auto-truncates at checkpoint), BULK-LOGGED (minimal logging for bulk operations), FULL (log grows until a log backup is taken)
Paired data fileAlways paired with at least one `.mdf` primary data file; additional data files use the `.ndf` extension
Max file sizeUp to 2 TB per log file on Windows NTFS/ReFS; a single database can have multiple `.ldf` files, each subject to this limit
EncryptionUnencrypted by default; automatically encrypted when Transparent Data Encryption (TDE) is enabled on the database
CompressionThe `.ldf` itself is stored uncompressed; log backups written to `.trn` or `.bak` files can use SQL Server backup compression
Checksum / integrityOptional torn-page detection and page checksums configurable at database level; engine validates the LSN chain on every recovery
Auto-growthSQL Server auto-grows the `.ldf` when it fills; growth increment is configurable in fixed MB or percentage; excessive auto-growth in small increments causes VLF fragmentation and slower recovery
Internal version bindingFormat is tied to the SQL Server engine version and database compatibility level; SQL Server 2022, for example, uses internal database version 904
OS platform supportWindows (all modern SQL Server versions); Linux and Docker containers (SQL Server 2017 and later via SQL Server on Linux)
MIME typeapplication/octet-stream (no dedicated MIME type registered for this format)
Direct accessNot intended for direct opening or parsing; accessed through SQL Server engine attachment, RESTORE DATABASE commands, or third-party log readers such as ApexSQL Log or Redgate SQL Log
ReleasedMicrosoft SQL Server (log architecture present since the Sybase-derived 4.x/6.x era, 1990s)
Latest versionFormat tied to the database compatibility/engine version (e.g. SQL Server 2022, internal db version 904)
Specificationlearn.microsoft.com

LDF conversions

Community Q&A

asked by users
Ask a quick question
Get help from people who work with LDF files. Be specific - include your system and software version.
No account needed · answers usually within a day

No questions yet - be the first to ask about LDF files.

Frequently asked questions

What is an LDF file?
It's the transaction log of a Microsoft SQL Server database - it records every change so the database can recover, roll back, and support point-in-time restore. It pairs with the .mdf data file.
How do I open an LDF file?
You don't open it directly. Attach or restore the database in SQL Server Management Studio (which uses both the .mdf and .ldf). The .ldf is binary and not human-readable.
Can I delete the LDF file to free space?
Not from a healthy database - it can make the database unusable. Instead back up the log (FULL recovery) or switch to SIMPLE recovery, then shrink the file with DBCC SHRINKFILE.
My LDF is missing - can I still attach the database?
Sometimes. SQL Server can rebuild a log for a cleanly shut-down database (attach with CREATE DATABASE ... FOR ATTACH_REBUILD_LOG), but any uncommitted transactions are lost. A corrupt-but-needed log requires a proper restore.
Why is my LDF file so large?
Usually FULL recovery model with no log backups, a long-running transaction, or replication holding the log. Take regular log backups (.trn) so the log can truncate, then shrink it.
Can I convert an LDF to PDF or read it as text?
No - it's undocumented binary. To read what changed, use a forensic log reader (ApexSQL Log/Redgate) that decodes transactions; to share data, export query results from SSMS.

References

1Microsoft - SQL Server transaction log architecturelearn.microsoft.com
2Microsoft - Manage the size of the transaction log filelearn.microsoft.com

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.MDMarkdown Document
3.CRDOWNLOADChrome Partial Download File
4.BINCD/DVD Disc Image (BIN/CUE)
5.PARTPartial Download File
6.NOMEDIAAndroid No-Media Marker File
7.RPMSGRestricted Permission Message
8.EXEWindows Executable (Portable Executable)
9.AVIFAV1 Image File Format (AVIF)
10.ICSiCalendar data file

Related extensions

.DBSQLite Database File
.DBFDatabase File (dBASE / xBase table)
.ACCDBMicrosoft Access Database (2007+)
.SQLSQL Script (Structured Query Language source / database dump)
.MDBMicrosoft Access Database (97-2003, Jet engine)
.FDBFirebird Database

Free file tools

An in-browser file identifier and image converter - everything runs on your device.

Open the toolbox

Browse file extensions A-Z