The SQL Server log and its maintenance, is a one of the important tasks for a Database Administrator. There are many optimized ways to configured SQL Server log, but then also we have to monitor the size of SQL Server logs.
Previously we have different method to find size of SQL Server Database Log like, DBCC commands, but now SQL Server 2012 introduced new dynamic management view name is dm_db_log_space_usage and using this dm-view we can easily calculate the size of the SQL Server Database log.
Below is a script to find the size of the SQL Server Database log.
DB_NAME(database_id) AS DatabaseName
,ROUND(CONVERT(FLOAT,total_log_size_in_bytes/1024)/1024,2) AS LogSizeInMB
,ROUND(CONVERT(FLOAT,used_log_space_in_bytes/1024)/1024,2) AS LogUsedSizeInMB
,ROUND(used_log_space_in_percent,2) AS LogUsedPercentInMB