Re: June 2005 EAL Question



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" <Steven@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C8DD9ADE-C5DF-4FC9-8BA4-407A65442202@xxxxxxxxxxxxxxxx
> 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" <Steven@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> news:52711C4F-D416-4000-BF9F-1BD19D7D124C@xxxxxxxxxxxxxxxx
>> >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\aspnet_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.Sinks.EventLogSink.SendMessageCore(LogEntry
>> > logEntry)
>> > at
>> > Microsoft.Practices.EnterpriseLibrary.Logging.Sinks.LogSink.SendMessage(LogEntry
>> > entry)
>> > at
>> > Microsoft.Practices.EnterpriseLibrary.Logging.Distributor.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.Sinks.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\aspnet_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?
>>
>>
>>


.



Relevant Pages

  • Connecting to Sharepoint Problem
    ... String bstrCurrentFolderUrl, Boolean& pbCanCustomizePages, Boolean& ... pVerGhostedSetupPath, UInt32& pdwPartCount, Object& pvarMetaData, ... pbstrRedirectUrl, Boolean& pbObjectIsList, Guid& pgListId, UInt32& ...
    (microsoft.public.biztalk.general)
  • Re: Connecting to Sharepoint Problem
    ... String bstrCurrentFolderUrl, Boolean& pbCanCustomizePages, Boolean& ... pVerGhostedSetupPath, UInt32& pdwPartCount, Object& pvarMetaData, ... pbstrRedirectUrl, Boolean& pbObjectIsList, Guid& pgListId, UInt32& ...
    (microsoft.public.biztalk.general)
  • RE: installation WSS 3.0
    ... <exception, Boolean breakConnection) ... <owningObject, SqlConnectionString connectionOptions, String newPassword, ... <newDatabaseId, String strDatabaseServer, String strDatabaseName, String ... <databaseServer, String databaseName, String databaseUsername, String ...
    (microsoft.public.windows.server.sbs)
  • Die Datei, die Sie zu speichern oder wiederherstellen versuchen, wurde von den Webserveradministrato
    ... bstrUrl, Byte bPageView, Byte bPageMode, Byte bGetBuildDependencySet, ... String bstrCurrentFolderUrl, Boolean& pbCanCustomizePages, Boolean& ... Object& pvarMultipleMeetingDoclibRootFolders, String& ...
    (microsoft.public.de.german.sharepointportalserver)
  • installation WSS 3.0
    ... Boolean redirectedUserInstance) ... identity, SqlConnectionString connectionOptions, Object providerInfo, String ... strDatabaseServer, String strDatabaseName, String strDatabaseUsername, String ... databaseServer, String databaseName, String databaseUsername, String ...
    (microsoft.public.windows.server.sbs)