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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:16:50+00:00 2026-06-03T03:16:50+00:00

I have some code that creates a new event source: EventLog.CreateEventSource(Source, LogName); I know

  • 0

I have some code that creates a new event source:

EventLog.CreateEventSource(Source, LogName);

I know that there’s a latency to creating this. I would like to set some default EventLog properties. I’m thinking something along the lines of:

EventLog log = new EventLog();
log.Source = Source;
log.MaximumKilobytes = 16384;
log.ModifyOverflowPolicy(OverflowAction.OverwriteAsNeeded, 0);

Is there some creative way of doing this at the same time?

I suppose I could periodically check EventLog.Exists(…) until it returns true, but it seems like there must be a cleaner way.

  • 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-03T03:16:50+00:00Added an answer on June 3, 2026 at 3:16 am

    This post is old, but I came here by searching with google, and thought this might be useful.

    If you are creating an event log source (instead of a new event log), the settings you are applying with ModifyOverflowPolicy are actually for the whole event log and not for the source you’ve just created.

    Therefore you should be able to do this:

    string LogName = "Application";
    EventLog.CreateEventSource(Source, LogName);
    
    EventLog log = new EventLog(LogName);
    log.MaximumKilobytes = 16384;
    log.ModifyOverflowPolicy(OverflowAction.OverwriteAsNeeded, 0);
    

    The property log.Source is only used if you’re going to write to the log: http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.source.aspx

    Else, you can write an informational log (e.g. Event Log created) to force the log creation:

    the log is not created until the first entry is written to it.
    http://msdn.microsoft.com/en-us/library/2awhba7a.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code that dynamically creates a new button through JavaScript that when
I have some code that creates a Process instance and later starts it. There's
I have some code that creates a bunch of UITextViews and puts them into
I have some javascript code that creates an img tag with a mouseover callback,
I have some Javascript code that creates 2 arrays: One for Product Category and
I have some code like this: EventLog.CreateEventSource(myApp, myAppLog); EventLog.WriteEntry(myApp, Test log message, EventLogEntryType.Error); Now,
we have some C++ code that we need to create a make file in.
I have some code that sets up a dictionary with some defualt values for
I have some code that gets the current logged in user. userID = request.session.get(_auth_user_id)
I have some code that is using SyncEnumerator. As you can see here ,

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.