Only do log backup if necessary in SQL Server
One alternative here is to calculate the size of active transactions in your transaction log by using DBCC LOGINFO.  Your logic would look something like this:

CREATE TABLE #vlfs(
   RecoveryUnitID int
  ,  FileID      int
  , FileSize    bigint
  , StartOffset bigint
  , FSeqNo      bigint
  , [Status]    bigint
  , Parity      bigint
  , CreateLSN   numeric(38)
);

DECLARE @MBthreshhold int

SELECT @MBthreshhold = 5 --Enter your threshhold in MB here

INSERT INTO #vlfs
EXEC ('DBCC LOGINFO')

IF (select sum(filesize/1024/1024) 
    from #vlfs
    where [Status] = 2) &gt; @MBthreshhold
BEGIN
    BACKUP LOG [foo] to &lt;&lt;backup location&gt;&gt;
END


Please note there are a lot of caveats here.  Your transaction log will never be completely empty and there is always something to backup to it.  You can use this to determine at what size point you want to actually run your backup, but this can be a HUGE risk to your Recovery Point Objective (RPO).  Your log backups will happen at variable times, meaning you can never guarantee the maximum amount of data loss you will incur in a disaster.  This sort of strategy should be pursued with extreme caution.