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 8181355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:29:35+00:00 2026-06-07T00:29:35+00:00

I am using log4net and would like to set up a process to notify

  • 0

I am using log4net and would like to set up a process to notify me when a record is written to the Log table. I would want it to run every hour or so. I would probably use this query:

SELECT * FROM Log 
WHERE Level = 'ERROR' 
AND Datediff(hh,[Date],getdate()) < 1 
  • 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-07T00:29:37+00:00Added an answer on June 7, 2026 at 12:29 am

    You could use a SQL Server Agent job (I assume you’re not using SQL Server Express). You will need to set up Database Mail. Then you can simply schedule a job that runs every hour that says:

    IF EXISTS 
    (
      SELECT 1 FROM dbo.[Log] 
        WHERE Level = 'ERROR' 
        AND [Date] >= DATEADD(HOUR, -1, GETDATE())
    )
    BEGIN
        EXEC msdb.dbo.sp_send_dbmail ...
    END
    

    Note that this science isn’t exact… if the job starts a few seconds after 8:00 it might miss an error that occurred at 7:00:01, and if you add a few seconds’ buffer, you might double-report an error that happened at 6:59:59.997. What you can consider doing to alleviate this is to store the last error you recorded somewhere, then you can add an additional WHERE clause:

    AND [Date] > (SELECT MAX(LastError) FROM dbo.LastErrorLog)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using log4net we would like to log all calls to our ASP.NET MVC controller
I would like to log in the Windows Event Viewer using log4net. I created
We have an application that logs using log4net. But we would like to delete
I would like to profile my NHibernate queries that I run from LINQPad using
I'm logging using log4net, and I want to log a id that is unique
I am using log4net to log to the console, and the %date conversionPattern value
I'm using log4Net for my logging. I also have the following set... <log4net debug=true>
I'm using log4net, and when i log messages my threadID will be duplicated inside
I would like to log data to a file in 2 byte languages (chinese,
I am using log4net and I was to save the log file in the

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.