Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. A question on having multiple source log to an eventlog

A question on having multiple source log to an eventlog

Scheduled Pinned Locked Moved C#
question
12 Posts 5 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L led mike

    Wow, is that production code with all those string literals? Are you kidding me?

    LongRange.Shooter wrote:

    I see the initialization message from sourceOne, but not from sourceTwo or sourceThree.

    Well I don't see any string literals for anything but someSource and OneSource in the code you posted so based on that seeing anything else is just not possible, period. ASIDE: The code you posted is horrible, literally.

    led mike

    L Offline
    L Offline
    LongRange Shooter
    wrote on last edited by
    #3

    Well, smartass, you don't see it because it is just the initialization code for someSource. The other initialization routines are the same, but someSource is replace with anotherSource, finalSource (for example). It is representative code of the initialization routine. And, BTW, in a recent technology testing I took I rated in the top 5% internationally as a C# coder. So do you have anything helpful to add or do you just like hearing yourself blow crap out your mouth?

    L A L 3 Replies Last reply
    0
    • L LongRange Shooter

      Well, smartass, you don't see it because it is just the initialization code for someSource. The other initialization routines are the same, but someSource is replace with anotherSource, finalSource (for example). It is representative code of the initialization routine. And, BTW, in a recent technology testing I took I rated in the top 5% internationally as a C# coder. So do you have anything helpful to add or do you just like hearing yourself blow crap out your mouth?

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #4

      Fuck off asshole

      led mike

      1 Reply Last reply
      0
      • L LongRange Shooter

        Well, smartass, you don't see it because it is just the initialization code for someSource. The other initialization routines are the same, but someSource is replace with anotherSource, finalSource (for example). It is representative code of the initialization routine. And, BTW, in a recent technology testing I took I rated in the top 5% internationally as a C# coder. So do you have anything helpful to add or do you just like hearing yourself blow crap out your mouth?

        A Offline
        A Offline
        Ashfield
        wrote on last edited by
        #5

        LongRange.Shooter wrote:

        in a recent technology testing I took I rated in the top 5% internationally as a C# coder.

        So was it an easy test then? ;)

        Bob Ashfield Consultants Ltd

        L 1 Reply Last reply
        0
        • L LongRange Shooter

          Well, smartass, you don't see it because it is just the initialization code for someSource. The other initialization routines are the same, but someSource is replace with anotherSource, finalSource (for example). It is representative code of the initialization routine. And, BTW, in a recent technology testing I took I rated in the top 5% internationally as a C# coder. So do you have anything helpful to add or do you just like hearing yourself blow crap out your mouth?

          L Offline
          L Offline
          leckey 0
          wrote on last edited by
          #6

          Let me get this staight...someone who is a site MVP and appears to be much more experienced than you told you that your code was not good. Yeah, he could have said it better, but calling him names is going to get you ignored permanently.

          LongRange.Shooter wrote:

          in a recent technology testing I took I rated in the top 5% internationally as a C# coder.

          Don't make claims like this unless you can prove it.

          CP Offenders: Over 50 offenders and growing! Current rant: "Me thinks CP needs an application process!" http://craptasticnation.blogspot.com/[^]

          L 1 Reply Last reply
          0
          • A Ashfield

            LongRange.Shooter wrote:

            in a recent technology testing I took I rated in the top 5% internationally as a C# coder.

            So was it an easy test then? ;)

            Bob Ashfield Consultants Ltd

            L Offline
            L Offline
            LongRange Shooter
            wrote on last edited by
            #7

            No it was the Robert Half test, locally most got only 75% and internationally the average was 79% while I scored 92%.

            A 1 Reply Last reply
            0
            • L leckey 0

              Let me get this staight...someone who is a site MVP and appears to be much more experienced than you told you that your code was not good. Yeah, he could have said it better, but calling him names is going to get you ignored permanently.

              LongRange.Shooter wrote:

              in a recent technology testing I took I rated in the top 5% internationally as a C# coder.

              Don't make claims like this unless you can prove it.

              CP Offenders: Over 50 offenders and growing! Current rant: "Me thinks CP needs an application process!" http://craptasticnation.blogspot.com/[^]

              L Offline
              L Offline
              LongRange Shooter
              wrote on last edited by
              #8

              Well, first of all I don't care who or what he is. He could answer the question or shut up. He did not answer the question nor did he behave in a fashion I'd expect of a site MVP. Secondly, his comment was one of a smartass not someone being helpful. Finally, my claim can be backed up by anyone that has access to the Robert Half testing scores...the results showed that locally here the average score was 72 and internationally it was 79 while I score 93. As to more experience....I've not seen anything that indicates he has more experience than me, especially since I've been writing code for 30 years and he's only been at it 15 years. I was also in a group that was part of the C# early adapters program and was working with Microsoft in finalizing the language within Visual Studio. Being a site MVP just means he either has no job or no life so he can jump in and answer a ton of questions before anyone else. I've been on this site for many years, been help to many people and I always try to provide help and not criticism, except where some constructive criticism can be of help. Finally with the exception of the use of the various literals in beta code, there is nothing wrong with my code that I can see. And if there was indeed a major issue with how I wrote the code I'd love to have some one point out what it is.

              1 Reply Last reply
              0
              • L LongRange Shooter

                I have a service that launches multiple threads. Each thread has a unique purpose and thus they are unique sources. I have a successfully created log file named OneSource and I want all of the sources logging events to that log file. Currently I have each thread initializing and accessing the EventLog with their own instances, the service itself does not do any logging. My first thread that I start successfully initialized and logs to the file but subsequent ones do not. Here is my eventlog initialization logic (some names were changed to protect the innocent :) :

                        #region Eventlog initialization
                
                        bool creationNeeded = false;
                
                        if ( !EventLog.SourceExists( "someSource" ) )
                            creationNeeded = true;
                        else if ( !EventLog.LogNameFromSourceName( "someSource", "." ).Equals( "OneSource" ) )
                        {
                            creationNeeded = true;    // management changed the log name again!
                            EventLog.DeleteEventSource( "someSource" );
                        }
                        if ( creationNeeded )
                        {
                            EventLog.CreateEventSource( "someSource", "OneSource" );
                        }
                
                        events = new System.Diagnostics.EventLog( "OneSource", ".", "someSource" );
                        events.WriteEntry( "someSource: Event log successfully started.", EventLogEntryType.Information );
                
                        #endregion
                

                FYI: We had management constantly changing their minds on the log file to use so we had to add code to make sure that the old log was deleted before we used the new logfile name and source. I see the initialization message from sourceOne, but not from sourceTwo or sourceThree. Nor do I see any logged messages from anything but sourceOne. Also...I see Information logged entries from sourceOne, but I never see anything logged where I use an AuditSuccess state for the log event. Any guidance would be appreciated.

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #9

                LongRange.Shooter wrote:

                I have a service that launches multiple threads. Each thread has a unique purpose and thus they are unique sources. I have a successfully created log file named OneSource and I want all of the sources logging events to that log file.

                A possibility exists: Is this service running under the LocalSystem account?? If so, it doesn't have the permissions to execute the EventLog.SourceExists method and will throw a SecurityException. Sources should be created by the service installer, not the service itself.

                A guide to posting questions on CodeProject[^]
                Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                     2006, 2007, 2008

                L 1 Reply Last reply
                0
                • D Dave Kreskowiak

                  LongRange.Shooter wrote:

                  I have a service that launches multiple threads. Each thread has a unique purpose and thus they are unique sources. I have a successfully created log file named OneSource and I want all of the sources logging events to that log file.

                  A possibility exists: Is this service running under the LocalSystem account?? If so, it doesn't have the permissions to execute the EventLog.SourceExists method and will throw a SecurityException. Sources should be created by the service installer, not the service itself.

                  A guide to posting questions on CodeProject[^]
                  Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                       2006, 2007, 2008

                  L Offline
                  L Offline
                  LongRange Shooter
                  wrote on last edited by
                  #10

                  Hi Dave. I'm not getting any exceptions during the process execution. But I am running under LocalSystem. I have security set to LinkDemand inheriting the rights from the service, and the service (for now) Asserts SecurityPermission. We are still in development and (as pointed out) we have a constantly changing environment at the moment. In fact we may be looking at yet another log file change in a few months just because the owning company is going to change the company name and they don't want a log file with the old name. Thanks.

                  D 1 Reply Last reply
                  0
                  • L LongRange Shooter

                    Hi Dave. I'm not getting any exceptions during the process execution. But I am running under LocalSystem. I have security set to LinkDemand inheriting the rights from the service, and the service (for now) Asserts SecurityPermission. We are still in development and (as pointed out) we have a constantly changing environment at the moment. In fact we may be looking at yet another log file change in a few months just because the owning company is going to change the company name and they don't want a log file with the old name. Thanks.

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #11

                    LongRange.Shooter wrote:

                    I'm not getting any exceptions during the process execution.

                    Since it's a service that runs under a different desktop you won't see any exceptions. The reason it will fail is because that method call digs into the registry to get the information, and the bulk of the registry is off-limits to the LocalSystem account.

                    A guide to posting questions on CodeProject[^]
                    Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                         2006, 2007, 2008

                    1 Reply Last reply
                    0
                    • L LongRange Shooter

                      No it was the Robert Half test, locally most got only 75% and internationally the average was 79% while I scored 92%.

                      A Offline
                      A Offline
                      Ashfield
                      wrote on last edited by
                      #12

                      Oh, I see. I've looked Robert Half up now, I didn't realise they were a recruitment agency, I thought they were a just a certification company, like say CompuTeach here in the UK. Obviously their tests will carry a lot of weight in the development community :-D ;)

                      Bob Ashfield Consultants Ltd

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups