How do i write the percentage sign "%" to the event log?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • K Viltersten

    How do i write the percentage sign "%" to the event log?

    It seems that when i try to write a
    percentage sign (%) into the event log
    using WriteEntry method, the log believes
    that i'm refering to some variable from
    command line.

    Is it a special character when logging?
    I've tried to Google it a while but i saw
    nobody giving a suggestion for a
    resolution.

    I've made a workaround by
    WriteEntry(mess age.Replace("%" ,"_"),...);
    but it's not exactly a solution filling me
    with pride.

    --
    Regards
    Konrad Viltersten
    ----------------------------------------
    May all spammers die an agonizing death;
    have no burial places; their souls be
    chased by demons in Gehenna from one room
    to another for all eternity and beyond.


  • Peter Morris

    #2
    Re: How do i write the percentage sign "%&quot ; to the event log?

    No idea, but I presume you have tried both %% and \%?


    Comment

    • K Viltersten

      #3
      Re: How do i write the percentage sign "%&quot ; to the event log?

      No idea, but I presume you have tried both %% and \%?

      I've tried "\%" and of course "\\%"
      but it didn't work. Now that i've tried
      the "%%" setup, i got DOUBLE percentage
      signes! As one would expect, that is...

      I'll go with this for now, unless someone
      has a better idea. Thanks Peter!

      --
      Regards
      Konrad Viltersten
      ----------------------------------------
      May all spammers die an agonizing death;
      have no burial places; their souls be
      chased by demons in Gehenna from one room
      to another for all eternity and beyond.


      Comment

      • Peter Duniho

        #4
        Re: How do i write the percentage sign "%&quot ; to the event log?

        On Fri, 19 Sep 2008 01:07:27 -0700, K Viltersten <tmp1@vilterste n.com>
        wrote:
        >No idea, but I presume you have tried both %% and \%?
        >
        I've tried "\%" and of course "\\%"
        but it didn't work. Now that i've tried
        the "%%" setup, i got DOUBLE percentage
        signes! As one would expect, that is...
        >
        I'll go with this for now, unless someone
        has a better idea. Thanks Peter!
        Unfortunately, the docs for the unmanaged version of this API say:

        Note that there is no way to log a string that contains %n,
        where n is an integer value. This syntax is used in IPv6
        addresses, so it is a problem to log an event message that
        contains an IPv6 address. For example, if the message text
        contains %1, the event viewer treats it as an insertion string.



        You didn't post a code example so we don't really know what you're trying
        to write to the event log, but I would guess that you're running into the
        same limitation in .NET, because .NET is using the underlying unmanaged
        API.

        On the bright side, it does imply that as long as you don't follow the %
        immediately with a digit, you'd be okay. So maybe you can put a space in
        or something.

        Pete

        Comment

        • K Viltersten

          #5
          Re: How do i write the percentage sign &quot;%&quot ; to the event log?

          >>No idea, but I presume you have tried both %% and \%?
          >>
          >I've tried "\%" and of course "\\%"
          >but it didn't work. Now that i've tried
          >the "%%" setup, i got DOUBLE percentage
          >signes! As one would expect, that is...
          >>
          >I'll go with this for now, unless someone
          >has a better idea. Thanks Peter!
          >
          Unfortunately, the docs for the unmanaged version of this API say:
          >
          Note that there is no way to log a string that contains %n,
          where n is an integer value. This syntax is used in IPv6
          addresses, so it is a problem to log an event message that
          contains an IPv6 address. For example, if the message text
          contains %1, the event viewer treats it as an insertion string.
          >

          >
          You didn't post a code example so we don't really know what you're trying
          to write to the event log, but I would guess that you're running into the
          same limitation in .NET, because .NET is using the underlying unmanaged
          API.
          Yes, that's what i went with - i put double percentage
          signs in there. It feels like a kindergarten solution; more
          a walk-around than a solution, really. Still, provided the
          infromation above (thanks for the link), i guess i'm
          already at the best position. Thanks!

          (As for the code, i don't think it'll help us a lot. I only want
          to log the string "%1%2%3".)

          --
          Regards
          Konrad Viltersten
          ----------------------------------------
          May all spammers die an agonizing death;
          have no burial places; their souls be
          chased by demons in Gehenna from one room
          to another for all eternity and beyond.


          Comment

          Working...