entlib4.1 with .net 4.0 not working

Topics: Logging Application Block
Aug 2, 2011 at 1:50 PM

 Software and Set up:

Windows Server 2008 R2
Visual Studio 2010
BizTalk Server 2010
ESB 2.1 (as i know there is some issue with this)
Entlib 4.1
and others..

Issue:

 


 

With the above set up, ent lib is not logging a very simple program to the rolling flat file or msmq.


I have to migrate a large application but since that is not working, i tried with a very simple one
as found in the blog (http://bloggingabout.net/blogs/dennis/archive/2009/07/21/quickstart-tutorial-into-enterprise-library-logging.aspx)


Setting this up logs the information to the event viewer but not to the file

Event Viewer details:

Log Name:      Application
Source:        Enterprise Library Logging
Date:          8/2/2011 9:26:21 AM
Event ID:      1
Task Category: None
Level:         Information
Keywords:      Classic
User:          N/A
Computer:      ------
Description:
Timestamp: 8/2/2011 1:26:21 PM
Message: Hello world
Category: General
Priority: -1
EventId: 1
Severity: Information
Title:
Machine: -----
Application Domain: LogDemo2_EntLib4.1.vshost.exe
Process Id: 10504
Process Name: D:\Development\MISC\Log\LogDemo2_EntLib4.1\bin\Debug\LogDemo2_EntLib4.1.vshost.exe
Win32 Thread Id: 10748
Thread Name:
Extended Properties:
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Enterprise Library Logging" />
    <EventID Qualifiers="0">1</EventID>
    <Level>4</Level>
    <Task>0</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2011-08-02T13:26:21.000000000Z" />
    <EventRecordID>197085</EventRecordID>
    <Channel>Application</Channel>
    <Computer>------</Computer>
    <Security />
  </System>
  <EventData>
    <Data>Timestamp: 8/2/2011 1:26:21 PM
Message: Hello world
Category: General
Priority: -1
EventId: 1
Severity: Information
Title:
Machine: -----
Application Domain: LogDemo2_EntLib4.1.vshost.exe
Process Id: 10504
Process Name: D:\Development\MISC\Log\LogDemo2_EntLib4.1\bin\Debug\LogDemo2_EntLib4.1.vshost.exe
Win32 Thread Id: 10748
Thread Name:
Extended Properties: </Data>
  </EventData>
</Event>

 


 


Code and app config:
The only code I have is in a windows application


Imports Microsoft.Practices.EnterpriseLibrary.Logging

 Try
            Logger.Write("Hello world")

        Catch ex As Exception
            MsgBox(ex.ToString())
        End Try

 

App.config

 

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </configSections>
  <loggingConfiguration name="Logging Application Block" tracingEnabled="true"
    defaultCategory="DefaultCategory" logWarningsWhenNoCategoriesMatch="true">
    <listeners>
      <add source="Enterprise Library Logging" formatter="MyFormatter"
        log="Application" machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Formatted EventLog TraceListener" />
      <add fileName="D:\Logs\rolling.log" footer="----------------------------------------"
        formatter="MyFormatter" header="----------------------------------------"
        rollFileExistsBehavior="Overwrite" rollInterval="None" rollSizeKB="0"
        timeStampPattern="yyyy-MM-dd" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        traceOutputOptions="None" filter="Off" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Rolling Flat File" />
    </listeners>
    <formatters>
      <add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;"
        type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="MyFormatter" />
    </formatters>
    <categorySources>
      <add switchValue="All" name="DefaultCategory">
        <listeners>
          <add name="Rolling Flat File" />
        </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="Formatted EventLog TraceListener" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
  </startup>
</configuration>


 


Another approach:
Followed the same steps mentioned in the blog (http://bloggingabout.net/blogs/dennis/archive/2009/07/21/quickstart-tutorial-into-enterprise-library-logging.aspx)
where the software is as below:
Windows Server 2003 R2
Visual Studio 2005
BizTalk Server 2006
ESB 2.0
Entlib 3.1
and others..

And this works fine.

 

 


 


Help:

I really need some help on this. I have been struggling for past few days with many different things and nothing is working for me. Eventually i need everything to go to MSMQ but since the flat file sample is not working so trying this to set up first.
Please let me know if I am missing something or if there is any known issue.


(
FYI - As per my earlier post, I think entlib5.0 will not work with esb2.1
http://entlib.codeplex.com/discussions/257435
)

 



Aug 3, 2011 at 6:20 AM

Hi,

The only reason I can think of is that the application has no privilege to write to that location. Can you verify if that is the case? Also, have you noticed any exceptions logged to the event viewer?

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
Contact Us

Aug 3, 2011 at 9:48 AM

Hi Noel:

I had given full access to everyone to that location. I tried couple of other location also. And I am administrator in that box.

I tried with 5 different server with same set up and it is not working on any of the system.

Do you have any documents that shows how to set up ent lib along with esb (except the other threads which i already went through).

There is nothing on the event viewer except the one that i posted above.

Thanks

Aug 3, 2011 at 10:20 AM

Unfortunately, we don't have this documentation, since ESB is already out of EntLib's scope. You can try asking from ESB Forum (http://social.msdn.microsoft.com/Forums/pl-PL/biztalkesb/threads). You might get better answers there. Moving on, your issue is kind of complicated. Most of the issue I've encountered is the opposite of yours (can't log with event viewer but logs with flat file). I suggest you to step through Entlib's Source Code so we can trace what's really happening during the logging process.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
Contact Us