log4net on .net framework 3.5

Could not find schema information for the element 'log4net'

Page 1 of 1

6 Replies - 25846 Views - Last Post: 20 May 2009 - 05:44 AM Rate Topic: -----

#1 ghinwa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 13-January 09

log4net on .net framework 3.5

Post icon  Posted 18 March 2009 - 08:16 AM

Hello,

i have tried to use log4net in a windows service on VS2008 - .Net Framework:
3.5,
I added the following in the app.config file :
<configSections>
   <section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
 </configSections>


 <log4net>
   <appender name="FileAppender" type="log4net.Appender.FileAppender">
	 <file value="C:\logfile.txt" />
	 <appendToFile value="true" />
	 <layout type="log4net.Layout.PatternLayout">
	   <conversionPattern value="%date [%thread] %-5level %logger
[%property{NDC}] - %message%newline" />
	 </layout>
   </appender>
   <root>
	 <level value="DEBUG" />
	 <appender-ref ref="FileAppender" />
   </root>
 </log4net>



but i am getting the below message:

"Message 5 Could not find schema information for the element
'log4net'. C:\Documents and Settings\Pv-User\My Documents\Visual Studio
2008\Projects\MyNewService\MyNewService\App.config 14 4
MyNewService"



what are the solutions for this problem? knowing that i cant downgrade to
.net 2.0 because several classes are using System.Linq.


Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: log4net on .net framework 3.5

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6246
  • View blog
  • Posts: 24,014
  • Joined: 23-August 08

Re: log4net on .net framework 3.5

Posted 18 March 2009 - 11:59 AM

Did you add a reference to log4net to the app? I'm running it with 3.5 without a problem.

<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />


and a very generic config at this point (still in development):
<log4net>
    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" >
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%ndc] - %message%newline" />
      </layout>
    </appender>
    <root>
      <level value="DEBUG" />
      <appender-ref ref="ConsoleAppender" />
    </root>
  </log4net>

Was This Post Helpful? 0
  • +
  • -

#3 ghinwa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 13-January 09

Re: log4net on .net framework 3.5

Posted 19 March 2009 - 04:19 AM

Thanks Jack!
it is now solved
and yes i was adding the reference to log4net but i was using this in the app.config:
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler>



now i have found another way used in the log4net samples :
 <section name="log4net" type="System.Configuration.IgnoreSectionHandler" />



and after i changed this, it worked fine.!
weird...do you have any idea why it wasnt working before this change and why it worked fine after it ?

Thanks again


View PostJackOfAllTrades, on 18 Mar, 2009 - 10:59 AM, said:

Did you add a reference to log4net to the app? I'm running it with 3.5 without a problem.

<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />


and a very generic config at this point (still in development):
<log4net>
    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" >
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%ndc] - %message%newline" />
      </layout>
    </appender>
    <root>
      <level value="DEBUG" />
      <appender-ref ref="ConsoleAppender" />
    </root>
  </log4net>

Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6246
  • View blog
  • Posts: 24,014
  • Joined: 23-August 08

Re: log4net on .net framework 3.5

Posted 19 March 2009 - 04:45 AM

No idea, as what you have should have worked. Glad you got it working, though.
Was This Post Helpful? 0
  • +
  • -

#5 ghinwa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 13-January 09

Re: log4net on .net framework 3.5

Posted 19 March 2009 - 05:29 AM

View PostJackOfAllTrades, on 19 Mar, 2009 - 03:45 AM, said:

No idea, as what you have should have worked. Glad you got it working, though.

Thanks :)
Was This Post Helpful? 0
  • +
  • -

#6 breezback  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 20-May 09

Re: log4net on .net framework 3.5

Posted 20 May 2009 - 02:14 AM

View Postghinwa, on 19 Mar, 2009 - 04:29 AM, said:

View PostJackOfAllTrades, on 19 Mar, 2009 - 03:45 AM, said:

No idea, as what you have should have worked. Glad you got it working, though.

Thanks :)


Hi,

Can we see the whole configuration stuff like web.config (if used) and app.config?
I would like to do the same so that all layers use the same config for log4net. I have the same problem, in ASP.NET it works fine but in my webservices (same assembly) I don't see any logging; it uses the same configuration (all configured in web.config) - which I'd like to change to use app.config from another common assembly/project.

thanks,

Ilan
Was This Post Helpful? 0
  • +
  • -

#7 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6246
  • View blog
  • Posts: 24,014
  • Joined: 23-August 08

Re: log4net on .net framework 3.5

Posted 20 May 2009 - 05:44 AM

Where are you calling your configurator? Is it in the runtime code, or is it at the Assembly level via an attribute?

In other words, are you doing this
XmlConfigurator.Configure(new System.IO.FileInfo(args[0]));



or this
[assembly: log4net.Config.XmlConfigurator(Watch=true)]


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1