To understand how the Write-ahead log works, it's important for what know how modified data are written to disk.
SQL Server maintains a buffer cache into which it reads data pages then data must be retrieved.
Data modifications is not made directly to disk, but is made to the copy of the page in the buffer cache.
The modification is not written to disk until a checkpoint occurs in the database, or the modification must being written to Disk so the buffer can is used to hold a new page.
Writing a modified data page from the buffer cache to disk is called flushing the page. A page modified in the cache, but not yet written to disk, is called a dirty page.
At the time a modification was made to a page in the buffer, a log record was built in the log cache that records the Modifi cation.
This log record must was written to disk before the associated dirty page was flushed from the buffer cache to disk.
If The dirty page is flushed before the log record was written, the dirty page creates a modification on the disk that Cann OT be rolled back if the server fails before the log record was written to disk.
SQL Server has logic this prevents a dirty page from being flushed before the associated log record is written.
Log Records is written to disk when the transactions is committed.
Data sources
=====================
Write-ahead Transaction Log
http://technet.microsoft.com/en-us/library/ms186259 (v=sql.105). aspx
How are changes to data in SQL Server dropped?