473,408 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

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(message.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.
Sep 19 '08 #1
4 3398
No idea, but I presume you have tried both %% and \%?
Sep 19 '08 #2
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.
Sep 19 '08 #3
On Fri, 19 Sep 2008 01:07:27 -0700, K Viltersten <tm**@viltersten.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.

http://msdn.microsoft.com/en-us/libr...79(VS.85).aspx

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
Sep 19 '08 #4
>>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.

http://msdn.microsoft.com/en-us/libr...79(VS.85).aspx

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.
Sep 22 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mark Richards | last post by:
The solutions for the following problems seems to be simple but I did not found a (convenient) solution: Assume we have a number of elements of the same type under a common parent e.g. <person...
1
by: Kevin Potter | last post by:
We have an application that has been running on IIS4 and IIS5 for quite some time, without problem We're now migrating to IIS6 (windows/2003), and have run into a what might? be a Javascipt...
2
by: bissatch | last post by:
Hi, I am trying to use JavaScript to write a table column on a web page. The code is as follows: <html> <head> <script> function displaycount() {
4
by: nsj | last post by:
How shall i use quotation marks within another in asp.net?
2
by: blue_nirvana | last post by:
Is there an event that fires when a user clicks the plus sign in a Master/Detail datagrid? It would be even better if I could catch when the user clicks the link to see the detail records. What...
5
by: bh | last post by:
I'm trying to convert the following statement to VB.NET: writer.Write(@"<some html here>"); I tried simply removing the semicolon, but VB chokes on the @-sign. Unfortunately, when searching...
3
by: cc50818j | last post by:
Hi, Can anyone suggest a Unix command or c-shell algorithm to simulate to behavior of "wall" command minus the "all users"? What I'm trying to do is to send a notice to just one particular user...
5
by: coldstar | last post by:
In an ASP Querystring, how do I include the double quotes in the code below at "1.0" part as text in my string? I have tried ""1.0"" and almost everything else but can't get it to work. I need...
27
by: duli | last post by:
Hi: I would like recommendations for books (in any language, not necessarily C++, C, python) which have walkthroughs for developing a big software project ? So starting from inception, problem...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.