c#


How can i write to the windows event log using C# (I'm getting some kind of error)?


I have written:
.
.
.
//Log exception to the event log
if (!EventLog.SourceExists("PodaHIS")) {
EventLog.CreateEventSource("PodaHIS", "Application");
}
EventLog eventLog = new EventLog();
eventLog.Log = "Application";
eventLog.Source = "PodaHIS";
eventLog.WriteEntry(error.ToString(), EventLogEntryType.Error);
I have also enabled read permission to LOCALMACHINE\ASPNET.
And in return i get:
The source was not found, but some or all event logs could not be searched. Inaccesible logs: Security.
Does anyone know why this is happening?
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\EventLog
What is need to do was grant the "Security" sub key of the EventLog Key read permission. After that i restarted my IIS.
this kb artical explains the steps required to give your asp process the correct security rights to write to the event log...
kb
If you have permission on the box that you want to write the event log to, then you can run a script that I wrote.
I think that a higher level of access is required to create a source in the event log. It's possible that the reference to Security log is coincidental and it is just reporting that as a possible cause. If you go in as an administrator and create the PodaHIS source yourself, you might then find that it can write to it.
What it your deployment environment? If it is Vista/Server 2008 then adding worker account into Administrators group won't work due to UAC.
This link explains the problem in details.
But I would recommend try creating an event source manually so ASPNET won't need to create it...

Related Links

Undefined symbols for architecture x86_64 “_main”
C# Black rectangle while focus by pressing tabulator key
ASP.NET Core MVC and EF Core 1.1
XMLDiff fails to recognize differences correcly?
Can a PrintDialog be modified?
Parse XML generated using C# Classes
How to take input in one line and separately store them in different variables
C# store contents from DB into list
Is it possible for Selenium to open an Excel Workbook pragmatically
MSAL. Detect revoked permissions and perform re-authorization
entity framework ado.net error SaveChanges()
Do I really need to clear a local list?
how to fill one jagged array from another one in c# [closed]
How to listen to events from a URI (C#)? [closed]
Web api internal server error [duplicate]
Stateless 3.0 - State Machine Library Best Practice

Categories

HOME
teradata
netty
sql-server-2014
cluster-analysis
openacc
opencv4android
opc-ua
ebay
checkpoint
multipartform-data
psexec
kendo-asp.net-mvc
meson-build
qt4
soap-client
core-data
fetch
urllib2
http-status-codes
oxid
camunda
responsive
pylint
md2
printf
restructuredtext
javaagents
onclicklistener
prepros
apdu
windows-mobile
jbossfuse
ios9
keil
scene7
powerbi-embedded
headphones
asp.net-webhooks
ragel
strategy-pattern
anypoint-studio
scalamock
linkurious
rexx
inner-join
gridgain
django-cors-headers
spring-cloud-bus
multivalue
ear
enet
richtext
seyren
dynatable
wicketstuff
ios-keyboard-extension
therubyracer
alarmmanager
hdr
recurring
change-password
vitamio
database-administration
phpdesigner
jsondoc
google-app-engine-php
clear
web-performance
github-for-mac
producer-consumer
mojolicious
biginsights
transport
updating
winforms-interop
grails-3.0.9
teamwork
optimistic-locking
system.io.packaging
nest-initiative
jsmpp
boofcv
vbaccelerator
maven-webstart-plugin
coinbase-php
microsoft-speech-platform
moonscript
nsregularexpression
shapado
nsscrollview
visual-leak-detector
jqzoom
virtual-printer
isgl3d
pex-and-moles
functional-specifications
xhtmlrenderer
cinder
datarelation
text-manipulation
for-xml
konsole
script-tag

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App