I just downloaded the June 2005 release and I want to set up basic logging to
log problems such as exceptions.
I have created a category named Exceptions with the following:
<category name="Exceptions">
<destinations>
<destination name="Event Log Destination" sink="Event Log Sink"
format="Text Formatter" />
</destinations>
</category>
Next I created a Sink to poit to the event log:
<sinks>
<sink xsi:type="EventLogSinkData" name="Event Log Sink"
eventLogName="Application" eventSourceName="DTS Logging" />
</sinks>
That is it now all I want to do is write the error to the application event
log. I attempt to do so with the following:
catch (Exception ex)
{
LogEntry log = new LogEntry();
log.EventId = 1;
log.Message = "test";
log.Category = "Exceptions";
log.Priority = 2;
Logger.Write(log);
}
The problem is I get the following warningin the event log:
Error logging with 'Event Log Sink' sink from configuration. The default log
sink will be used instead to process the message.
Summary for Enterprise Library Distributor Service:
======================================
-->
Message:
Timestamp: 8/3/2005 8:55:36 AM
Message: test
Category: Exceptions
Priority: 2
EventId: 1
Severity: Unspecified
Title:
Machine: EXTREMEDEV
App Domain: /LM/W3SVC/1/Root/DefenseTravelSystem-8-127675689321875000
ProcessId: 1912
Process Name: \\?\C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\a spnet_wp.exe
Thread Name:
Win32 ThreadId:3280
Extended Properties:
--> MachineName: EXTREMEDEV
--> TimeStamp: 8/3/2005 1:55:37 PM
--> FullName: Microsoft.Practices.EnterpriseLibrary.Common, Version=1.1.0.0,
Culture=neutral, PublicKeyToken=null
--> AppDomainName: /LM/W3SVC/1/Root/DefenseTravelSystem-8-127675689321875000
--> WindowsIdentity: EXTREMEDEV\ASPNET
Exception Information Details:
======================================
Exception Type: System.Security.SecurityException
PermissionType: NULL
PermissionState: NULL
GrantedSet: NULL
RefusedSet: NULL
Message: Requested registry access is not allowed.
TargetSite: Microsoft.Win32.RegistryKey OpenSubKey(System.String, Boolean)
HelpLink: NULL
Source: mscorlib
StackTrace Information Details:
======================================
at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
at System.Diagnostics.EventLog.FindSourceRegistration (String source,
String machineName, Boolean readOnly)
at System.Diagnostics.EventLog.SourceExists(String source, String
machineName)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType type, Int32 eventID, Int16 category)
at
Microsoft.Practices.EnterpriseLibrary.Logging.Sink s.EventLogSink.SendMessageCore(LogEntry logEntry)
at
Microsoft.Practices.EnterpriseLibrary.Logging.Sink s.LogSink.SendMessage(LogEntry entry)
at
Microsoft.Practices.EnterpriseLibrary.Logging.Dist ributor.LogDistributor.DistributeLogEntry(LogEntry log, CategoryData category)
As well I get the the following information entry:
An error occurred while the Distributor was processing the message. Please
check your configuration files for errors or typos. Verify that your sinks
are reachable (queues exist, permissions are set, database exists, etc...)
Sink failed because: System.Security.SecurityException: Requested registry
access is not allowed.
at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
at System.Diagnostics.EventLog.FindSourceRegistration (String source,
String machineName, Boolean readOnly)
at System.Diagnostics.EventLog.SourceExists(String source, String
machineName)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType type, Int32 eventID, Int16 category)
at
Microsoft.Practices.EnterpriseLibrary.Logging.Sink s.EventLogSink.SendMessageCore(LogEntry logEntry).
Message:
Timestamp: 8/3/2005 8:55:36 AM
Message: test
Category: Exceptions
Priority: 2
EventId: 1
Severity: Unspecified
Title:
Machine: EXTREMEDEV
App Domain: /LM/W3SVC/1/Root/DefenseTravelSystem-8-127675689321875000
ProcessId: 1912
Process Name: \\?\C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\a spnet_wp.exe
Thread Name:
Win32 ThreadId:3280
Extended Properties:
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Any ideas? 4 4567
yes. You have a web app, don't you?
Web apps run in a special account that lacks most of the privileges of
normal user accounts. Depending on your setup, windows apps will behave the
same way depending on the account you run them under.
Since you configured that the event should should use its own event source,
the block attempts to create the event source the first time you try to
write to the log. This throws a permission error. After the event source
is created, this problem doesn't happen any more.
So, you have a couple of options:
1) the correct way to use a custom event source is to use an installer to
create your app, and put code into your installer to install the event
source. If you want to continue to use a custom event source, do this.
2) run your app under admin privileges once. That will create the event
source. Then you can switch back to normal permissions to keep running.
Hope this helps,
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Steven" <St****@discussions.microsoft.com> wrote in message
news:52**********************************@microsof t.com... I just downloaded the June 2005 release and I want to set up basic logging to log problems such as exceptions.
I have created a category named Exceptions with the following: <category name="Exceptions"> <destinations> <destination name="Event Log Destination" sink="Event Log Sink" format="Text Formatter" /> </destinations> </category>
Next I created a Sink to poit to the event log: <sinks> <sink xsi:type="EventLogSinkData" name="Event Log Sink" eventLogName="Application" eventSourceName="DTS Logging" /> </sinks>
That is it now all I want to do is write the error to the application event log. I attempt to do so with the following:
catch (Exception ex) { LogEntry log = new LogEntry(); log.EventId = 1; log.Message = "test"; log.Category = "Exceptions"; log.Priority = 2;
Logger.Write(log); }
The problem is I get the following warningin the event log: Error logging with 'Event Log Sink' sink from configuration. The default log sink will be used instead to process the message.
Summary for Enterprise Library Distributor Service: ====================================== --> Message: Timestamp: 8/3/2005 8:55:36 AM Message: test Category: Exceptions Priority: 2 EventId: 1 Severity: Unspecified Title: Machine: EXTREMEDEV App Domain: /LM/W3SVC/1/Root/DefenseTravelSystem-8-127675689321875000 ProcessId: 1912 Process Name: \\?\C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\a spnet_wp.exe Thread Name: Win32 ThreadId:3280 Extended Properties: --> MachineName: EXTREMEDEV --> TimeStamp: 8/3/2005 1:55:37 PM --> FullName: Microsoft.Practices.EnterpriseLibrary.Common, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null --> AppDomainName: /LM/W3SVC/1/Root/DefenseTravelSystem-8-127675689321875000 --> WindowsIdentity: EXTREMEDEV\ASPNET
Exception Information Details: ====================================== Exception Type: System.Security.SecurityException PermissionType: NULL PermissionState: NULL GrantedSet: NULL RefusedSet: NULL Message: Requested registry access is not allowed. TargetSite: Microsoft.Win32.RegistryKey OpenSubKey(System.String, Boolean) HelpLink: NULL Source: mscorlib
StackTrace Information Details: ====================================== at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) at System.Diagnostics.EventLog.FindSourceRegistration (String source, String machineName, Boolean readOnly) at System.Diagnostics.EventLog.SourceExists(String source, String machineName) at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category) at Microsoft.Practices.EnterpriseLibrary.Logging.Sink s.EventLogSink.SendMessageCore(LogEntry logEntry) at Microsoft.Practices.EnterpriseLibrary.Logging.Sink s.LogSink.SendMessage(LogEntry entry) at Microsoft.Practices.EnterpriseLibrary.Logging.Dist ributor.LogDistributor.DistributeLogEntry(LogEntry log, CategoryData category)
As well I get the the following information entry: An error occurred while the Distributor was processing the message. Please check your configuration files for errors or typos. Verify that your sinks are reachable (queues exist, permissions are set, database exists, etc...)
Sink failed because: System.Security.SecurityException: Requested registry access is not allowed. at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) at System.Diagnostics.EventLog.FindSourceRegistration (String source, String machineName, Boolean readOnly) at System.Diagnostics.EventLog.SourceExists(String source, String machineName) at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category) at Microsoft.Practices.EnterpriseLibrary.Logging.Sink s.EventLogSink.SendMessageCore(LogEntry logEntry).
Message: Timestamp: 8/3/2005 8:55:36 AM Message: test Category: Exceptions Priority: 2 EventId: 1 Severity: Unspecified Title: Machine: EXTREMEDEV App Domain: /LM/W3SVC/1/Root/DefenseTravelSystem-8-127675689321875000 ProcessId: 1912 Process Name: \\?\C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\a spnet_wp.exe Thread Name: Win32 ThreadId:3280 Extended Properties:
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Any ideas?
Thank you.. I just want to write to the default application event log and so
far so good however I am now getting the following error:
The description for Event ID ( 1 ) in Source ( Application ) cannot be
found. The local computer may not have the necessary registry information or
message DLL files to display messages from a remote computer. You may be able
to use the /AUXSOURCE= flag to retrieve this description; see Help and
Support for details. The following information is part of the event:
Timestamp: 8/3/2005 7:13:31 PM
Also how do I reflect DTS as the source description versus Application as it
is now?
<sinks>
<sink xsi:type="EventLogSinkData" name="Event Log Sink"
eventLogName="Application" eventSourceName="Application" />
<sink xsi:type="FlatFileSinkData" name="Flat File Sink"
fileName="trace.log" header="----------------------------------------"
footer="----------------------------------------" />
</sinks>
<categories>
<category name="General">
<destinations>
<destination name="Event Log Destination" sink="Event Log Sink"
format="Text Formatter" />
</destinations>
</category>
</categories>
"Nick Malik [Microsoft]" wrote: yes. You have a web app, don't you?
Web apps run in a special account that lacks most of the privileges of normal user accounts. Depending on your setup, windows apps will behave the same way depending on the account you run them under.
Since you configured that the event should should use its own event source, the block attempts to create the event source the first time you try to write to the log. This throws a permission error. After the event source is created, this problem doesn't happen any more.
So, you have a couple of options: 1) the correct way to use a custom event source is to use an installer to create your app, and put code into your installer to install the event source. If you want to continue to use a custom event source, do this. 2) run your app under admin privileges once. That will create the event source. Then you can switch back to normal permissions to keep running.
Hope this helps,
-- --- Nick Malik [Microsoft] MCSD, CFPS, Certified Scrummaster http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not representative of my employer. I do not answer questions on behalf of my employer. I'm just a programmer helping programmers. -- "Steven" <St****@discussions.microsoft.com> wrote in message news:52**********************************@microsof t.com...I just downloaded the June 2005 release and I want to set up basic logging to log problems such as exceptions.
I have created a category named Exceptions with the following: <category name="Exceptions"> <destinations> <destination name="Event Log Destination" sink="Event Log Sink" format="Text Formatter" /> </destinations> </category>
Next I created a Sink to poit to the event log: <sinks> <sink xsi:type="EventLogSinkData" name="Event Log Sink" eventLogName="Application" eventSourceName="DTS Logging" /> </sinks>
That is it now all I want to do is write the error to the application event log. I attempt to do so with the following:
catch (Exception ex) { LogEntry log = new LogEntry(); log.EventId = 1; log.Message = "test"; log.Category = "Exceptions"; log.Priority = 2;
Logger.Write(log); }
The problem is I get the following warningin the event log: Error logging with 'Event Log Sink' sink from configuration. The default log sink will be used instead to process the message.
Summary for Enterprise Library Distributor Service: ====================================== --> Message: Timestamp: 8/3/2005 8:55:36 AM Message: test Category: Exceptions Priority: 2 EventId: 1 Severity: Unspecified Title: Machine: EXTREMEDEV App Domain: /LM/W3SVC/1/Root/DefenseTravelSystem-8-127675689321875000 ProcessId: 1912 Process Name: \\?\C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\a spnet_wp.exe Thread Name: Win32 ThreadId:3280 Extended Properties: --> MachineName: EXTREMEDEV --> TimeStamp: 8/3/2005 1:55:37 PM --> FullName: Microsoft.Practices.EnterpriseLibrary.Common, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null --> AppDomainName: /LM/W3SVC/1/Root/DefenseTravelSystem-8-127675689321875000 --> WindowsIdentity: EXTREMEDEV\ASPNET
Exception Information Details: ====================================== Exception Type: System.Security.SecurityException PermissionType: NULL PermissionState: NULL GrantedSet: NULL RefusedSet: NULL Message: Requested registry access is not allowed. TargetSite: Microsoft.Win32.RegistryKey OpenSubKey(System.String, Boolean) HelpLink: NULL Source: mscorlib
StackTrace Information Details: ====================================== at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) at System.Diagnostics.EventLog.FindSourceRegistration (String source, String machineName, Boolean readOnly) at System.Diagnostics.EventLog.SourceExists(String source, String machineName) at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category) at Microsoft.Practices.EnterpriseLibrary.Logging.Sink s.EventLogSink.SendMessageCore(LogEntry logEntry) at Microsoft.Practices.EnterpriseLibrary.Logging.Sink s.LogSink.SendMessage(LogEntry entry) at Microsoft.Practices.EnterpriseLibrary.Logging.Dist ributor.LogDistributor.DistributeLogEntry(LogEntry log, CategoryData category)
As well I get the the following information entry: An error occurred while the Distributor was processing the message. Please check your configuration files for errors or typos. Verify that your sinks are reachable (queues exist, permissions are set, database exists, etc...)
Sink failed because: System.Security.SecurityException: Requested registry access is not allowed. at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) at System.Diagnostics.EventLog.FindSourceRegistration (String source, String machineName, Boolean readOnly) at System.Diagnostics.EventLog.SourceExists(String source, String machineName) at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category) at Microsoft.Practices.EnterpriseLibrary.Logging.Sink s.EventLogSink.SendMessageCore(LogEntry logEntry).
Message: Timestamp: 8/3/2005 8:55:36 AM Message: test Category: Exceptions Priority: 2 EventId: 1 Severity: Unspecified Title: Machine: EXTREMEDEV App Domain: /LM/W3SVC/1/Root/DefenseTravelSystem-8-127675689321875000 ProcessId: 1912 Process Name: \\?\C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\a spnet_wp.exe Thread Name: Win32 ThreadId:3280 Extended Properties:
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Any ideas?
BTW, it is in fact a web app....
I have the following that the admin may run to establish the event source:
using System;
using System.Diagnostics;
using System.ComponentModel;
using System.Configuration.Install;
namespace EventLogSourceInstaller
{
/// <summary>
/// Summary description for EventLogSourceInstaller.
/// </summary>
[RunInstaller(true)]
public class MyEventLogInstaller: Installer
{
private EventLogInstaller myEventLogInstaller;
public MyEventLogInstaller()
{
// Create an instance of 'EventLogInstaller'.
myEventLogInstaller = new EventLogInstaller();
// Set the 'Source' of the event log, to be created.
myEventLogInstaller.Source = "Defense Travel System";
// Set the 'Log' that the source is created in.
myEventLogInstaller.Log = "Defense Travel System";
// Add myEventLogInstaller to 'InstallerCollection'.
Installers.Add(myEventLogInstaller);
}
public static void Main()
{
}
}
}
My question is am I am going about logging the exception thrown properly?
try
{
ctrl.Attributes["class"] = "MenuItemSelected";
// set title
LiteralTitle.Text = _title;
}
catch (Exception ex)
{
LogEntry log = new LogEntry();
log.Category = "General";
log.Message = ex.Message;
log.EventId = 1;
log.Title = "ERROR: Page_Load method in MilitaryNavigation";
Logger.Write(log);
}
"Nick Malik [Microsoft]" wrote: yes. You have a web app, don't you?
Web apps run in a special account that lacks most of the privileges of normal user accounts. Depending on your setup, windows apps will behave the same way depending on the account you run them under.
Since you configured that the event should should use its own event source, the block attempts to create the event source the first time you try to write to the log. This throws a permission error. After the event source is created, this problem doesn't happen any more.
So, you have a couple of options: 1) the correct way to use a custom event source is to use an installer to create your app, and put code into your installer to install the event source. If you want to continue to use a custom event source, do this. 2) run your app under admin privileges once. That will create the event source. Then you can switch back to normal permissions to keep running.
Hope this helps,
-- --- Nick Malik [Microsoft] MCSD, CFPS, Certified Scrummaster http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not representative of my employer. I do not answer questions on behalf of my employer. I'm just a programmer helping programmers. -- "Steven" <St****@discussions.microsoft.com> wrote in message news:52**********************************@microsof t.com...I just downloaded the June 2005 release and I want to set up basic logging to log problems such as exceptions.
I have created a category named Exceptions with the following: <category name="Exceptions"> <destinations> <destination name="Event Log Destination" sink="Event Log Sink" format="Text Formatter" /> </destinations> </category>
Next I created a Sink to poit to the event log: <sinks> <sink xsi:type="EventLogSinkData" name="Event Log Sink" eventLogName="Application" eventSourceName="DTS Logging" /> </sinks>
That is it now all I want to do is write the error to the application event log. I attempt to do so with the following:
catch (Exception ex) { LogEntry log = new LogEntry(); log.EventId = 1; log.Message = "test"; log.Category = "Exceptions"; log.Priority = 2;
Logger.Write(log); }
The problem is I get the following warningin the event log: Error logging with 'Event Log Sink' sink from configuration. The default log sink will be used instead to process the message.
Summary for Enterprise Library Distributor Service: ====================================== --> Message: Timestamp: 8/3/2005 8:55:36 AM Message: test Category: Exceptions Priority: 2 EventId: 1 Severity: Unspecified Title: Machine: EXTREMEDEV App Domain: /LM/W3SVC/1/Root/DefenseTravelSystem-8-127675689321875000 ProcessId: 1912 Process Name: \\?\C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\a spnet_wp.exe Thread Name: Win32 ThreadId:3280 Extended Properties: --> MachineName: EXTREMEDEV --> TimeStamp: 8/3/2005 1:55:37 PM --> FullName: Microsoft.Practices.EnterpriseLibrary.Common, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null --> AppDomainName: /LM/W3SVC/1/Root/DefenseTravelSystem-8-127675689321875000 --> WindowsIdentity: EXTREMEDEV\ASPNET
Exception Information Details: ====================================== Exception Type: System.Security.SecurityException PermissionType: NULL PermissionState: NULL GrantedSet: NULL RefusedSet: NULL Message: Requested registry access is not allowed. TargetSite: Microsoft.Win32.RegistryKey OpenSubKey(System.String, Boolean) HelpLink: NULL Source: mscorlib
StackTrace Information Details: ====================================== at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) at System.Diagnostics.EventLog.FindSourceRegistration (String source, String machineName, Boolean readOnly) at System.Diagnostics.EventLog.SourceExists(String source, String machineName) at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category) at Microsoft.Practices.EnterpriseLibrary.Logging.Sink s.EventLogSink.SendMessageCore(LogEntry logEntry) at Microsoft.Practices.EnterpriseLibrary.Logging.Sink s.LogSink.SendMessage(LogEntry entry) at Microsoft.Practices.EnterpriseLibrary.Logging.Dist ributor.LogDistributor.DistributeLogEntry(LogEntry log, CategoryData category)
As well I get the the following information entry: An error occurred while the Distributor was processing the message. Please check your configuration files for errors or typos. Verify that your sinks are reachable (queues exist, permissions are set, database exists, etc...)
Sink failed because: System.Security.SecurityException: Requested registry access is not allowed. at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) at System.Diagnostics.EventLog.FindSourceRegistration (String source, String machineName, Boolean readOnly) at System.Diagnostics.EventLog.SourceExists(String source, String machineName) at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category) at Microsoft.Practices.EnterpriseLibrary.Logging.Sink s.EventLogSink.SendMessageCore(LogEntry logEntry).
Message: Timestamp: 8/3/2005 8:55:36 AM Message: test Category: Exceptions Priority: 2 EventId: 1 Severity: Unspecified Title: Machine: EXTREMEDEV App Domain: /LM/W3SVC/1/Root/DefenseTravelSystem-8-127675689321875000 ProcessId: 1912 Process Name: \\?\C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\a spnet_wp.exe Thread Name: Win32 ThreadId:3280 Extended Properties:
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Any ideas?
I haven't dug under the code details in EAL, so I'm relying on what I can
tell from the Framework documentation...
I'm going to suggest that you comment out the line that sets the 'category'
parameter to a string. The API allows a category to be written to the event
log, but only as an integer, and only if you have already mapped category
strings to these integers. As far as I can tell, the Framework has no way
to do this. It has to be done through registry updates. I do not know if
the EAL does this updating... but your installer does not.
Therefore, try commenting out the following line: log.Category = "General";
and see if that helps.
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Steven" <St****@discussions.microsoft.com> wrote in message
news:C8**********************************@microsof t.com... BTW, it is in fact a web app....
I have the following that the admin may run to establish the event source: using System; using System.Diagnostics; using System.ComponentModel; using System.Configuration.Install;
namespace EventLogSourceInstaller { /// <summary> /// Summary description for EventLogSourceInstaller. /// </summary> [RunInstaller(true)] public class MyEventLogInstaller: Installer { private EventLogInstaller myEventLogInstaller; public MyEventLogInstaller() { // Create an instance of 'EventLogInstaller'. myEventLogInstaller = new EventLogInstaller(); // Set the 'Source' of the event log, to be created. myEventLogInstaller.Source = "Defense Travel System"; // Set the 'Log' that the source is created in. myEventLogInstaller.Log = "Defense Travel System"; // Add myEventLogInstaller to 'InstallerCollection'. Installers.Add(myEventLogInstaller); } public static void Main() { } }
}
My question is am I am going about logging the exception thrown properly? try { ctrl.Attributes["class"] = "MenuItemSelected";
// set title LiteralTitle.Text = _title; } catch (Exception ex) { LogEntry log = new LogEntry(); log.Category = "General"; log.Message = ex.Message; log.EventId = 1; log.Title = "ERROR: Page_Load method in MilitaryNavigation";
Logger.Write(log); }
"Nick Malik [Microsoft]" wrote:
yes. You have a web app, don't you?
Web apps run in a special account that lacks most of the privileges of normal user accounts. Depending on your setup, windows apps will behave the same way depending on the account you run them under.
Since you configured that the event should should use its own event source, the block attempts to create the event source the first time you try to write to the log. This throws a permission error. After the event source is created, this problem doesn't happen any more.
So, you have a couple of options: 1) the correct way to use a custom event source is to use an installer to create your app, and put code into your installer to install the event source. If you want to continue to use a custom event source, do this. 2) run your app under admin privileges once. That will create the event source. Then you can switch back to normal permissions to keep running.
Hope this helps,
-- --- Nick Malik [Microsoft] MCSD, CFPS, Certified Scrummaster http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not representative of my employer. I do not answer questions on behalf of my employer. I'm just a programmer helping programmers. -- "Steven" <St****@discussions.microsoft.com> wrote in message news:52**********************************@microsof t.com... >I just downloaded the June 2005 release and I want to set up basic >logging >to > log problems such as exceptions. > > I have created a category named Exceptions with the following: > <category name="Exceptions"> > <destinations> > <destination name="Event Log Destination" sink="Event Log > Sink" > format="Text Formatter" /> > </destinations> > </category> > > Next I created a Sink to poit to the event log: > <sinks> > <sink xsi:type="EventLogSinkData" name="Event Log Sink" > eventLogName="Application" eventSourceName="DTS Logging" /> > </sinks> > > That is it now all I want to do is write the error to the application > event > log. I attempt to do so with the following: > > catch (Exception ex) > { > LogEntry log = new LogEntry(); > log.EventId = 1; > log.Message = "test"; > log.Category = "Exceptions"; > log.Priority = 2; > > > Logger.Write(log); > } > > The problem is I get the following warningin the event log: > Error logging with 'Event Log Sink' sink from configuration. The > default > log > sink will be used instead to process the message. > > > Summary for Enterprise Library Distributor Service: > ====================================== > --> > Message: > Timestamp: 8/3/2005 8:55:36 AM > Message: test > Category: Exceptions > Priority: 2 > EventId: 1 > Severity: Unspecified > Title: > Machine: EXTREMEDEV > App Domain: /LM/W3SVC/1/Root/DefenseTravelSystem-8-127675689321875000 > ProcessId: 1912 > Process Name: > \\?\C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\a spnet_wp.exe > Thread Name: > Win32 ThreadId:3280 > Extended Properties: > --> MachineName: EXTREMEDEV > --> TimeStamp: 8/3/2005 1:55:37 PM > --> FullName: Microsoft.Practices.EnterpriseLibrary.Common, > Version=1.1.0.0, > Culture=neutral, PublicKeyToken=null > --> AppDomainName: > /LM/W3SVC/1/Root/DefenseTravelSystem-8-127675689321875000 > --> WindowsIdentity: EXTREMEDEV\ASPNET > > Exception Information Details: > ====================================== > Exception Type: System.Security.SecurityException > PermissionType: NULL > PermissionState: NULL > GrantedSet: NULL > RefusedSet: NULL > Message: Requested registry access is not allowed. > TargetSite: Microsoft.Win32.RegistryKey OpenSubKey(System.String, > Boolean) > HelpLink: NULL > Source: mscorlib > > StackTrace Information Details: > ====================================== > at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean > writable) > at System.Diagnostics.EventLog.FindSourceRegistration (String source, > String machineName, Boolean readOnly) > at System.Diagnostics.EventLog.SourceExists(String source, String > machineName) > at System.Diagnostics.EventLog.WriteEntry(String message, > EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) > at System.Diagnostics.EventLog.WriteEntry(String message, > EventLogEntryType type, Int32 eventID, Int16 category) > at > Microsoft.Practices.EnterpriseLibrary.Logging.Sink s.EventLogSink.SendMessageCore(LogEntry > logEntry) > at > Microsoft.Practices.EnterpriseLibrary.Logging.Sink s.LogSink.SendMessage(LogEntry > entry) > at > Microsoft.Practices.EnterpriseLibrary.Logging.Dist ributor.LogDistributor.DistributeLogEntry(LogEntry > log, CategoryData category) > > As well I get the the following information entry: > An error occurred while the Distributor was processing the message. > Please > check your configuration files for errors or typos. Verify that your > sinks > are reachable (queues exist, permissions are set, database exists, > etc...) > > Sink failed because: System.Security.SecurityException: Requested > registry > access is not allowed. > at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean > writable) > at System.Diagnostics.EventLog.FindSourceRegistration (String source, > String machineName, Boolean readOnly) > at System.Diagnostics.EventLog.SourceExists(String source, String > machineName) > at System.Diagnostics.EventLog.WriteEntry(String message, > EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) > at System.Diagnostics.EventLog.WriteEntry(String message, > EventLogEntryType type, Int32 eventID, Int16 category) > at > Microsoft.Practices.EnterpriseLibrary.Logging.Sink s.EventLogSink.SendMessageCore(LogEntry > logEntry). > > Message: > Timestamp: 8/3/2005 8:55:36 AM > Message: test > Category: Exceptions > Priority: 2 > EventId: 1 > Severity: Unspecified > Title: > Machine: EXTREMEDEV > App Domain: /LM/W3SVC/1/Root/DefenseTravelSystem-8-127675689321875000 > ProcessId: 1912 > Process Name: > \\?\C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\a spnet_wp.exe > Thread Name: > Win32 ThreadId:3280 > Extended Properties: > > For more information, see Help and Support Center at > http://go.microsoft.com/fwlink/events.asp. > > Any ideas? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Philadelphia XML User Group |
last post by:
Philadelphia XML Users' Group
NEXT MEETING: June 13th, 6:00 to 8:00 pm
The Users' Group is an open organization that invites participation
from anyone in the Delaware Valley and Greater...
|
by: jmays |
last post by:
Dev Direct June 2005 News Round Up
http://www.devdirect.com/content/newsletters/dev200506.htm
Dev Direct provides an authoritative and up-to-date catalog of 1000's
of developer tools and...
|
by: Lester Knutsen |
last post by:
Washington Area IBM Informix/DB2 User Group meeting - June 7, 2005
--------------------------------------------------------------
Mark the date, our next user group meeting will be another...
|
by: Scott Nonnenberg [MSFT] |
last post by:
As part of our standard every-other-thursday chat series, the C# Team is
having a Post-TechEd wrapup chat this Thursday. We're trying to get our
session content online before then, but only DEV370...
|
by: Mythran |
last post by:
I have installed NDoc and VSHIK2003. If I install a clean Enterprise
Library June 2005, how can I go about getting the exact same documentation
that is installed with the release (in the...
|
by: Steven |
last post by:
I just downloaded the June 2005 release and I want to set up basic logging to
log problems such as exceptions.
I have created a category named Exceptions with the following:
<category...
|
by: Manoj Nair |
last post by:
Hi all,
For our application we need to create a wrapper for the instrumentation and
logging block of the Enterprise library june 2005 release.
Can any one send a link which can help us in this ?...
|
by: Mukesh |
last post by:
Hi
I m using
microsoft application blocks Enterprise Library june 2005 with .net
framework 1.1 and VStudio2003 And C# as coding language
Sql server 2000 database
the project is running...
|
by: =?Utf-8?B?TWlrZSBEb3Zlcg==?= |
last post by:
Hi,
I hope this is the appropriate group to ask the following question.
How does one install the June 2005 Enterprise library (for .NET 1.1) on a
production windows 2003 Internet server?
My...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |