0
1

I tried to use the manual sample to get Xtensive logs in our log4net infrastructure.

  <configSections>
    ...
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
    <section name="Xtensive.Core.IoC" type="Xtensive.Core.IoC.Configuration.ConfigurationSection, Xtensive.Core"/>
  </configSections>

  <Xtensive.Core.IoC>
    <containers>
      <container>
        <types>
          <type type="Xtensive.Core.Diagnostics.ILogProvider, Xtensive.Core"
          mapTo="Xtensive.Adapters.log4net.LogProviderImplementation, Xtensive.Adapters.log4net" singleton="true"/>
        </types>
      </container>
    </containers>
  </Xtensive.Core.IoC>

I can see the logs in console (without using log4net) but I can't get them in log4net.

Do you have a working complete app.config sample? I'm sure I'm missing something here...

EDIT: I got an exception with Xtensive diagnostics build :

System.Configuration.ConfigurationErrorsException occurred
  Message=Unrecognized element 'types'. 
  Source=System.Configuration
  BareMessage=Unrecognized element 'types'.
  Filename=xxx.exe.config
  Line=53
  StackTrace:
       at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
       at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
       at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
       at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
       at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
       at System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission)
       at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
       at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
       at System.Configuration.ConfigurationManager.GetSection(String sectionName)
       at Xtensive.Core.IoC.ServiceContainer.Create(String name) in c:\Temp\DataObjects.Net\Xtensive.Core\Xtensive.Core\IoC\ServiceContainer.cs:line 256
  InnerException:

asked Sep 15 '10 at 04:51

olorin's gravatar image

olorin
358868792

edited Sep 17 '10 at 03:56

We'll investigate the issue shortly and will provide web.config sample as result.

(Sep 17 '10 at 01:12) Alex Yakunin Alex%20Yakunin's gravatar image

I forgot : this is for a windows console application, not a web application.

(Sep 17 '10 at 03:13) olorin olorin's gravatar image

Added exception got with diagnostics build.

(Sep 17 '10 at 03:57) olorin olorin's gravatar image

One Answer:

See http://goo.gl/aTID - it explains available methods pretty well. We should add XSD for this as well.

So the section should look like:

<Xtensive.Core.IoC>
  <containers>
    <container [name="ContainerName"]>
      <explicit>
        <!-- Explicit service <-> type mapping -->
        <add type="ServiceTypeOrInterface" 
             mapTo="ServiceImplementationType"
             [singleton="true|false"]
             [name="ServiceName"]/>
      </explicit>
      <auto>
        <!-- Automatic service <-> type mapping (based on attributes) -->
        <add type="ServiceImplementationType" />
        ...
      </auto>
    </container>
  </containers>
</Xtensive.Core.IoC>

Applying this to log4net:

<Xtensive.Core.IoC>
  <containers>
    <container>
      <explicit>
        <add type="Xtensive.Core.Diagnostics.ILogProvider, Xtensive.Core"
             mapTo="Xtensive.Adapters.log4net.LogProviderImplementation, Xtensive.Adapters.log4net" singleton="true"/>
      </types>
    </container>
  </containers>
</Xtensive.Core.IoC>

answered Sep 17 '10 at 10:46

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412

Sorry, didn't test this, but it should work.

There are tests for IoC framework configuration - I used XML from these tests, but I didn't try to run this.

(Sep 17 '10 at 10:48) Alex Yakunin Alex%20Yakunin's gravatar image

It didn't work for me : I don't get DO's log in log4net.

(Sep 20 '10 at 02:50) olorin olorin's gravatar image

Any news on this? I'm not against a old fashioned C# code line to activate logging to log4net.

(Sep 22 '10 at 04:01) olorin olorin's gravatar image

I'll develop a sample for this in few hours (a bit busy now, but shortly there will be some time on this).

Sorry for delay.

(Sep 22 '10 at 06:10) Alex Yakunin Alex%20Yakunin's gravatar image

Well this is not that urgent! I just think it would practical for us, but this is not required right now.

(Sep 22 '10 at 06:24) olorin olorin's gravatar image

Ok - postponed this a bit. We'll add this as sample to upcoming DO4 update.

(Sep 22 '10 at 13:48) Alex Yakunin Alex%20Yakunin's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

Subscription:

Once you sign in you will be able to subscribe for any updates here

Tags:

×574
×5
×1

Asked: Sep 15 '10 at 04:51

Seen: 4,052 times

Last updated: Sep 22 '10 at 13:48

powered by OSQA