The Event Log File is full
Asked Answered
P

7

3

I keep getting this error message when trying to write to the Event log from a console app. Here's how i write to it

public static void WriteToEventLog(Exception ex)
    {
        string mySource = "Export Task";
        if (!EventLog.SourceExists(mySource))
            EventLog.CreateEventSource(mySource, "Application");

        EventLog myLog = new EventLog();
        myLog.Source = mySource;

        myLog.WriteEntry(ex.ToString());

    }

Does anyone know why this is happening and how i can fix it?

Plasticine answered 19/8, 2009 at 14:10 Comment(1)
See this Page: howtogeek.com/howto/windows/…Haemo
G
12

To me it sounds like:

  • It's happening because the event log is full.
  • Fix it by emptying the event log.

If this isn't the case, please edit your question to make it clear that you believe the event log isn't full, and how you came to this conclusion.

Geomorphic answered 19/8, 2009 at 14:11 Comment(4)
I think he may expect a means to empty it programatically, not manually via the event viewerLlovera
Another solution is to increase the capacity of the event log.Metalliferous
@Vinko: Given the "Does anyone know why this is happening" I'm not sure... definitely needs more information.Geomorphic
The reason it's full can be found.. in the log files. Just see what takes up so many entries and what they're about.. That's the root cause.Jam
P
9

I had the same error on Windows XP using Visual C# 2010 Express and this is what worked for me:

Go to Start->Control Panel->Administrative Tools->Event Viewer

Then select Action->Properties and select "Overwrite Events as Needed"

You could also increase the maximum size of the log.

Plugboard answered 13/12, 2012 at 20:45 Comment(0)
I
6

If you open the event viewer, right click on the event log in question and select "properties" you can see the event log size. You can make it larger or change the options below it to say "Overwrite events as needed".

Ilex answered 19/8, 2009 at 14:22 Comment(0)
B
3

Most likely scenario, you're using the default Application log which is usually written to by almost any app on your machine (just like the one you wrote). Over time the event log fills up and reaches its maximum

So my suggestion would be to create a new custom event log instead of reusing the "Application" log. That way you can catch this exception (which is a valid case) and handle it by calling EventLog.Clear & retrying the write event operation. Also check if you're flooding the event log, log responsibly.

On the other hand, you could also change the event log properties for the Application log. (Event Viewer, Bring up properties on the Application log node) - You can specify the max size of the log (512 KB) as well as how to handle wrapping e.g. Overwrite entries older than 7 days when the max size is reached. (This seems to be the default on my WinXP machine). But you'd have to do this on every machine... but its something that you could try

Bathrobe answered 19/8, 2009 at 14:21 Comment(0)
B
2

Custom event log sources have a default size of 512k. This has bit me several times. You can override this to make it a much more sane size (especially if you are writing a log of information for debug purposes).

Barron answered 19/8, 2009 at 14:21 Comment(0)
E
0

Have you tried following code?

log.ModifyOverflowPolicy(OverflowAction.OverwriteAsNeeded, log.MinimumRetentionDays);
Evert answered 23/1, 2013 at 12:50 Comment(0)
C
0

Start Event viewer Choose your event log and right click, hit 'Properties' Bump up the maximum log size in KB (this must be in multiples of 64 KB, but if you enter a number it will be corrected if this is not the case to be a multiple. A sound value in production could be 100 MB for example, so 100,000 for example could be inputted here.

Note, in production you probably do not want to overwrite events if the log still gets full. This is indicative of erroneous logging or an error which is frequently logged and occurs.

Event log properties

Conspire answered 18/1, 2022 at 15:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.