Logging help

Topics: Logging Application Block
Apr 4, 2011 at 11:34 AM

Hi

Im trying to log to eg the eventlog from a service (running as an console in debug).

If the eventlog does not excist, nothing is happening - finally I change the logname to a log that existed, and got the following error: 

Can anyone help me solve the issue? :-) (I have a little test app running - and that is logging fine to the same eventlog - it is the same logging configuration aswell... 

 

******* the eventlog error ***********

- System 
  - Provider 
   [ Name]  Enterprise Library Logging    - EventID 6352 
   [ Qualifiers]  0     Level 2     Task 0     Keywords 0x80000000000000    - TimeCreated 
   [ SystemTime]  2011-04-04T10:48:21.000000000Z     EventRecordID 906     Channel EventLogMyLogName     Computer MyMachine     Security  
- EventData 
   Timestamp: 2011-04-04 10:48:21 Message: Tracing to LogSource 'General' failed. Processing for other sources will continue. See summary information below for more information. Should this problem persist, stop the service and check the configuration file(s) for possible error(s) in the configuration of the categories and sinks. Summary for Enterprise Library Distributor Service: ====================================== --> Message: Timestamp: 2011-04-04 10:48:21 Message: Test Message 112 Category: General Priority: -1 EventId: 1 Severity: Information Title: Machine: MyMachine App Domain: CS.OBO.TB.Service.vshost.exe ProcessId: 6628 Process Name: D:\Data\Solution\OBO\WINSVC\TB\Source\BusinessLogic\TBusService\bin\RunServiceAsConsole\CS.OBO.TB.Service.vshost.exe Thread Name: Win32 ThreadId:6980 Extended Properties: --> MachineName: MyMachine --> TimeStamp: 2011-04-04 10:48:21 --> FullName: Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null --> AppDomainName: CS.OBO.TB.Service.vshost.exe --> WindowsIdentity: TSNET\admkaou01 Exception Information Details: ====================================== Exception Type: System.IO.DirectoryNotFoundException Message: Could not find a part of the path 'C:\Windows\system32\WBEM\Framework\root\EnterpriseLibrary\Microsoft.Practices.EnterpriseLibrary.Logging_SN__Version_5.0.414.0.cs'. Data: System.Collections.ListDictionaryInternal TargetSite: Void WinIOError(Int32, System.String) HelpLink: NULL Source: mscorlib StackTrace Information Details: ====================================== at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) at System.IO.StreamReader..ctor(String path, Boolean detectEncodingFromByteOrderMarks) at System.Management.Instrumentation.SchemaNaming.get_Code() at System.Management.Instrumentation.InstrumentedAssembly..ctor(Assembly assembly, SchemaNaming naming) at System.Management.Instrumentation.Instrumentation.Initialize(Assembly assembly) at System.Management.Instrumentation.Instrumentation.GetInstrumentedAssembly(Assembly assembly) at System.Management.Instrumentation.Instrumentation.Fire(Object eventData) at Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.WmiTraceListener.TraceData(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, Object data) at Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.TraceListenerWrapper.TraceData(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, Object data) at Microsoft.Practices.EnterpriseLibrary.Logging.LogSource.TraceData(TraceEventType eventType, Int32 id, LogEntry logEntry, TraceListenerFilter traceListenerFilter, TraceEventCache traceEventCache) at Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl.ProcessLog(LogEntry log, TraceEventCache traceEventCache) Category: Priority: -1 EventId: 6352 Severity: Error Title: Machine: Mymachine App Domain: CS.OBO.TB.Service.vshost.exe ProcessId: 6628 Process Name: D:\Data\Solution\OBO\WINSVC\TB\Source\BusinessLogic\TBusService\bin\RunServiceAsConsole\CS.OBO.TB.Service.vshost.exe Thread Name: Win32 ThreadId:6980 Extended Properties:  

Apr 5, 2011 at 2:41 AM

So you're saying you have 2 applications both contains code for logging.  The other one works, while the other one doesn't?  Are you sure you exactly have the same config for both application?  What is the value of the Source property of the Formatted Event Log Trace Listener?  Any other difference to note between the two applications?

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

 

Apr 5, 2011 at 2:32 PM

Hi! :-)

 

I have copy'ed the configuration setting from one file to another - so they should be exactly the same... 

The main difference from the 2 programs, is that the app that works is a windows form and the one that does not, is a Windows Service (running as an console in debug mode). 

I have googled on Windows services and IntLib - and can see some has trouble with network service account rights... I have tried to make sure everyone has access to the eventlog, just in case - But the error I get is not a access-thing (it seems)?

 

Below is the config file. 

<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null" requirePermission="true" />    

 

<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">    <listeners>      <add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null"          listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null"          source="Enterprise Library Logging" formatter="Text Formatter"          log="EventLogNameSco" machineName="." traceOutputOptions="None" />      <add name="WMITraceListener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.WmiTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null"          listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.WmiTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null"          traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId" />    </listeners>    <formatters>      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null"          template="Timestamp: {timestamp}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Title:{title}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} - {value}{newline})}"          name="Text Formatter" />    </formatters>    <categorySources>      <add switchValue="All" name="General">        <listeners>          <add name="WMITraceListener" />          <add name="Event Log Listener" />        </listeners>      </add>    </categorySources>    <specialSources>      <allEvents switchValue="All" name="All Events" />      <notProcessed switchValue="All" name="Unprocessed Category" />      <errors switchValue="All" name="Logging Errors &amp; Warnings">        <listeners>          <add name="Event Log Listener" />        </listeners>      </errors>    </specialSources>  </loggingConfiguration>

Apr 6, 2011 at 12:27 AM

I haven't encountered this issue before but did you check if the file ('C:\Windows\system32\WBEM\Framework\root\EnterpriseLibrary\Microsoft.Practices.EnterpriseLibrary.Logging_SN__Version_5.0.414.0.cs) mentioned exists on your machine?  I'm not familiar with this file as well but it does exists on my machine.  If it exists yet the error says it can't find it, then it might be a permission issue.

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 6, 2011 at 3:28 AM

Hi! :-)

The file and file-structure does not exist from "enterpriseLibrary" and ahead! Im not familiar with the file either... and I am thinking that the file should not need to exists... ?

(damn you haven't encountered this before.. *S*)

I think you are right about the permission issue - I have given everyone full control to the concrete eventlog... no change... 

Best regards

Karina

Apr 6, 2011 at 4:26 AM
Edited Apr 6, 2011 at 4:27 AM

Well, I did encounter somewhat similar issues before but I haven't seen this error message until now.  I'll investigate more on this.  But just to confirm, the other program which can log to the event log runs on the same machine, right? 

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 6, 2011 at 6:31 AM

I just noticed that there's some inconsistency in your config.  In the declaration of the loggingConfiguration section in the configSections, it indicates a value for the PublicKeyToken attribute while in the loggingConfiguration itself, that attribute is set to null.  If you're using the strongly-named assemblies (those which are in the installation folder (Program Files), make sure that the PublicKeyToken attribute has a value instead of null.  This should be automatic if you edited your config in the configuration tool.   While this somehow doesn't seem to be related, I'll advise you to fix it first.

Going on to the real issue, I think this may be caused by permissions associated to using WMI.  Does your service runs under the Network Service account?  If yes, see if this thread will help you.

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 6, 2011 at 8:47 AM

Solved! :-)

When my esteemed colleague, Marion Espino, heard about the problem - he smiled a little - and said it was a problem between 32 and 64 bits. - and he was right! :-)

The easiest way to solve this problem is to copy
from: Windows \ SysWOW64 \ wbem \ Framework \ root \ enterprise library
to: Windows \ System32 \ wbem \ Framework \ root \ enterprise library

Apr 6, 2011 at 8:52 AM

Thanks for sharing this :)

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com