Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8320937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:50:27+00:00 2026-06-08T22:50:27+00:00

I need to create an application or service which notifies when the log file

  • 0

I need to create an application or service which notifies when the log file increases above a certain size. Either an email or something else.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T22:50:28+00:00Added an answer on June 8, 2026 at 10:50 pm

    Here’s the whole scripted agent task with the above logic in it. See 3 variables to set at the top. (Operator name can be null if you only want to generate a windows application log error)

    USE [msdb]
    GO
    Declare @AdminUserName varchar(255)
    Declare @Operator varchar(255)
    Declare @EmailNotify bit
    Set @AdminUserName = N'YOUR SYSADMIN USER'
    set @Operator = N'YOUR OPERATOR NAME'
    Set @EmailNotify = 1
    
    
    /****** Object:  Job [Transaction Logfile Size Monitoring]    Script Date: 08/02/2012 15:39:11 ******/
    BEGIN TRANSACTION
    DECLARE @ReturnCode INT
    SELECT @ReturnCode = 0
    /****** Object:  JobCategory [[Uncategorized (Local)]]]    Script Date: 08/02/2012 15:39:11 ******/
    IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'[Uncategorized (Local)]' AND category_class=1)
    BEGIN
    EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', @type=N'LOCAL', @name=N'[Uncategorized (Local)]'
    IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
    
    END
    Declare @NotifyLevel int
    If @EmailNotify = 1 Begin 
    set @NotifyLevel =2 end 
    else begin
    set @NotifyLevel=0 
    set @Operator=null
    end
    
    DECLARE @jobId BINARY(16)
    EXEC @ReturnCode =  msdb.dbo.sp_add_job @job_name=N'Transaction Logfile Size Monitoring', 
                @enabled=1, 
                @notify_level_eventlog=0, 
                @notify_level_email=@NotifyLevel, 
                @notify_level_netsend=0, 
                @notify_level_page=0, 
                @delete_level=0, 
                @description=N'No description available.', 
                @category_name=N'[Uncategorized (Local)]', 
                @owner_login_name=@AdminUserName, 
                @notify_email_operator_name=@Operator, @job_id = @jobId OUTPUT
    IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
    /****** Object:  Step [Monitor Logfile Size]    Script Date: 08/02/2012 15:39:11 ******/
    EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'Monitor Logfile Size', 
                @step_id=1, 
                @cmdexec_success_code=0, 
                @on_success_action=1, 
                @on_success_step_id=0, 
                @on_fail_action=2, 
                @on_fail_step_id=0, 
                @retry_attempts=0, 
                @retry_interval=0, 
                @os_run_priority=0, @subsystem=N'TSQL', 
                @command=N'Declare @LogSize int;
    Declare @LogName varchar(255);
    Declare @LogFile varchar(2000);
    
    select  Top 1 @LogName=name,@LogFile=physical_name,@LogSize = convert(float,size) * 8192 / (1024 * 1024) from    sys.master_files
    where   type_desc = ''LOG'' Order by size desc
    
    IF (@LogSize > 10240)
    BEGIN
    Declare @AlertString varchar(5000)
    set @AlertString = @LogName + '' : '' + @LogFile + '' has reached a size of '' + Convert(varchar(20),@LogSize) + '' MB.''
    RAISERROR(@AlertString, 18,1) with LOG
    END
    ELSE
    BEGIN
    RAISERROR(''Transaction Log monitoring complete'', 0, 1)
    END', 
                @database_name=N'master', 
                @flags=4
    IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
    EXEC @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1
    IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
    EXEC @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id=@jobId, @name=N'Hourly Logfile Check', 
                @enabled=1, 
                @freq_type=4, 
                @freq_interval=1, 
                @freq_subday_type=8, 
                @freq_subday_interval=1, 
                @freq_relative_interval=0, 
                @freq_recurrence_factor=0, 
                @active_start_date=20120802, 
                @active_end_date=99991231, 
                    @active_start_time=0, 
                @active_end_time=235959, 
                @schedule_uid=N'18435d90-4ca0-4c7a-a8a9-c81f347ba32c'
    IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
    EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'
    IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
    COMMIT TRANSACTION
    GOTO EndSave
    QuitWithRollback:
        IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION
    EndSave:
    
    GO
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a application which is similar to those we will get
I am trying to create a Service for my application which will negotiate Bluetooth
I need an application/service which runs in the background and generate bills on a
In a WCF Service, I need to create a variable which should be accessible
I have a Windows Service Application in which i create WCF services in it.
I need to create a WCF Service that will have a download file function.
I want to create an application with JayData + WCF/RIA Services but i need
I need to create application logs to capture users signing in/out and their requests,
I need to create an application capable to modify and manage files on IOS.
So, just like the title says, I need to create an application that gets

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.