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 4596
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: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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,...
| |