CommonLogging + log4net not working

671 views
Skip to first unread message

Diego Koga

unread,
Mar 1, 2016, 9:10:29 AM3/1/16
to Quartz.NET
Guys, I need some help.

I am trying to use this with Quartz.Net, but I am getting this error. I found some possible solutions and nothing could make it work, that's why I am creating this issue here. Maybe it is my mistake, could you point in the right direction?

These are the messages:

  • Failed obtaining configuration for Common.Logging from configuration section 'common/logging'.
  • Configuration system failed to initialize
  • Only one element allowed per config file and if present must be the first child of the root element.

I create a brand new console application, added this nuget package Common.Logging.Log4Net1213 which is being used on the Quartz.Net server, and created the app.config file..

All them we can see in this repo: https://github.com/dikoga/CommonLoggingUsingLog4NetSample


*** I post it as an issue in GitHub: https://github.com/net-commons/common-logging/issues/118


Thanks,

Mark Gillen

unread,
Mar 1, 2016, 2:44:48 PM3/1/16
to quar...@googlegroups.com
Here's are the relevant sections from an app config of mine. I use both.

<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging"/>
</sectionGroup>
</configSections>

<common>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net1213">
<arg key="configType" value="INLINE"/>
</factoryAdapter>
</logging>
</common>

<log4net>
<!--Console appender isn't enabled when running as a service.-->
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{ISO8601} [%-5p] %c{3}(%line) - %m%n" />
</layout>
</appender>
<!--Windows event log appender is enabled when running as a service.-->
<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
<applicationName value="TritonDataSyncApp" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{ISO8601} [%-5p] [%t] %l - %m%n" />
</layout>
</appender>
<!--Application log (located in "Logs" subdirectory under where the service is installed) is local text file.-->
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="Logs//MyApp-" />
<datePattern value="yyyyMMdd'.log'" />
<appendToFile value="true" />
<rollingStyle value="Composite" />
<maxSizeRollBackups value="3" />
<maximumFileSize value="1MB" />
<preserveLogFileNameExtension value="true" />
<countDirection value="1" />
<param name="StaticLogFileName" value="false" />
<lockingModel type="log4net.Appender.FileAppender+InterProcessLock" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{ISO8601} %-5level %m%n" />
</layout>
</appender>
<!-- FileAppender.ExclusiveLock, FileAppender.MinimalLock and FileAppender.InterProcessLock-->
<!-- Logging levels for Log4Net. In order of increasing priority. "yyyyMMdd-HH.lo\g"-->
<!--
•ALL
•DEBUG
•INFO
•WARN
•ERROR
•FATAL
•OFF
-->
<!--Create the Application log separately with a different logging level than the "root".-->
<logger name="MyApp">
<level value="INFO" />
<appender-ref ref="ConsoleAppender" />
<appender-ref ref="RollingFile" />
</logger>
</log4net>


<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>

<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="log4net" publicKeyToken="1b44e1d426115821" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.2.13.0" newVersion="1.2.13.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.3.0.0" newVersion="3.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Common.Logging.Core" publicKeyToken="af08829b84f0328e" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.3.0.0" newVersion="3.3.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

Best Regards,
Mark Gillen

----- Diego Koga <dik...@gmail.com> wrote:
> Guys, I need some help.
>
> I am trying to use this with Quartz.Net, but I am getting this error. I
> found some possible solutions and nothing could make it work, that's why I
> am creating this issue here. Maybe it is my mistake, could you point in the
> right direction?
>
> These are the messages:
>
> - Failed obtaining configuration for Common.Logging from configuration
> section 'common/logging'.
> - Configuration system failed to initialize
> - Only one element allowed per config file and if present must be the
> first child of the root element.
>
> I create a brand new console application, added this nuget package
> Common.Logging.Log4Net1213 which is being used on the Quartz.Net server,
> and created the app.config file..
>
> All them we can see in this repo:
> https://github.com/dikoga/CommonLoggingUsingLog4NetSample
>
>
> *** I post it as an issue in
> GitHub: https://github.com/net-commons/common-logging/issues/118
>
>
> Thanks,
>
> --
> You received this message because you are subscribed to the Google Groups "Quartz.NET" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to quartznet+...@googlegroups.com.
> To post to this group, send email to quar...@googlegroups.com.
> Visit this group at https://groups.google.com/group/quartznet.
> For more options, visit https://groups.google.com/d/optout.

Dave Waterworth

unread,
Mar 6, 2016, 9:02:25 PM3/6/16
to Quartz.NET
I had this problem, I resolved by installing the Common.Loggin.Log4Net1211 nuget package first then Quartz (you need to remove all the related nuget packages first to do this)

I found that versions of Common.Logging.Log4Net12xx for versions > 1211 appeared to install the wrong version of log4net.dll which is why I used Common.Loggin.Log4Net1211 as this installed the 1.2.11 log4net dll

Dave


Diego Koga

unread,
Mar 11, 2016, 7:40:38 AM3/11/16
to Quartz.NET
Hi Dave, 

That fix my issue too. Thanks a lot!
Reply all
Reply to author
Forward
0 new messages