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

I want to learn how to program 3D/2D applications (Games) in C#. What should I read? [closed]
Splitting a SQL String per Command
Assigning values to richtextbox [closed]
C# How to use multiple interface implementations
how to create an ASP.NET Web Page to manage folders and files for loading and reading to an external server?
Thread safe calls to windows form are freezing the application
A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property
Is it possible to create bidirectional relationships using only data annotations with EF Code First?
Do not unsubscribe from COMObject events can cause memory leak although I use Marshal.FinalReleaseComObject?
Parent-Child Matrix Chaining/Order Hierarchy
Invoke a non generic method with generic arguments defined in a generic class
Display ticket remaining time
Can't call Click Event on dynamic button
OdbcConnection.GetSchema(“TABLES”); not working
How to filter data in RDLC report?
defining characters to ignore while matching strings C# [closed]

Categories

HOME
classification
kendo-ui
azure-active-directory
domain-driven-design
redhawksdr
atlassian-fisheye
hibernate-mapping
cdn
webpack-dev-server
openbsd
aspectj
eclipse-orion
minimum
webseal
exchange-transport-agents
bookmarklet
amazon-data-pipeline
windows-phone
draw2d
gomobile
datazen-server
dev-c++
hololens
screen-scraping
pushbullet
pumping-lemma
handle
chartist.js
ckeditor4.x
jira-zephyr
pydub
visual-studio-community
marionette
edsdk
andengine
log4net-configuration
imdb
storefront
snapkit
node-soap
rtos
traitsui
http-proxy
cocoa-scripting
javafxports
campaign-monitor
maven-2
hippocms
extern
mongoid5
ngrok
lfe
usernotifications
tapply
intervention
piranha-cms
ocpjp
google-chrome-storage
openxava
dotnet-cli
htop
multi-select
apache-commons-cli
esprima
android-music-player
mavlink
access-violation
cascading
yfiles
computability
joomla3.3
callfire
targetprocess
copy-on-write
parseexception
data-quality-services
fiware-health
fxmlloader
report-builder2.0
grunt-contrib-connect
api-eveonline
vundle
livescript
triplestore
xpand
telerik-appbuilder
ant-contrib
smartxls
code-smell
farpoint-spread
infor-eam
mahara
adabas
qmainwindow
phone-state-listener
django-tinymce
socketasynceventargs
unordered-set
scsf
copyfile
service-layer
silverlight-2.0
linq-to-mysql
qprocess
dojox.gfx
onresize
disk-based
unauthorized

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