2017-12-08 1 views
0

그래서 나는 이상한 이상한 문제가 있습니다. Azure 웹 작업이 있습니다. 여기에 log4net을 추가하고 싶습니다.웹 작업에서 Log4net : 인식 할 수없는 구성 섹션 log4net -하지만 상단에 configSection이 있습니다

다음 web.config 파일이 있습니다.이 파일은 작동하는 웹 응용 프로그램과 동일한 요소가 있습니다. 내가 대시 보드에서 푸른 웹 작업에 대한 로그를 열 때, 그러나

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <connectionStrings> 
    <!-- The format of the connection string is "DefaultEndpointsProtocol=https;AccountName=NAME;AccountKey=KEY" --> 
    <!-- For local execution, the value can be set either in this config file or through environment variables --> 
    <add name="AzureWebJobsDashboard" connectionString="" /> 
    <add name="AzureWebJobsStorage" connectionString="" /> 
    <add name="DefaultConnection" connectionString="" providerName="System.Data.SqlClient" /> 

    </connectionStrings> 
    <configSections> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> 
    </configSections> 
    <startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> 
    </startup> 
    <appSettings> 

    <!--Azure Storage--> 
    <add key="StorageConnectionString" value="" /> 
    <add key="DefaultStorageContainer" value="" /> 

    <!-- GatawayApi SMS --> 
    <add key="GatewayApiServiceEnabled" value="FALSE" /> 
    <add key="GatewayApiKey" value="" /> 
    <add key="GatewayApiSecret" value="" /> 

    <!-- Mandrill mail--> 
    <add key="MandrillApiServiceEnabled" value="TRUE" /> 
    <add key="MandrillApiKey" value="" /> 
    </appSettings> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 

    <log4net debug="true"> 
    <appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender"> 
     <bufferSize value="1" /> 
     <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> 
     <connectionStringName value="DefaultConnection" /> 
     <commandText value="INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)" /> 
     <parameter> 
     <parameterName value="@log_date" /> 
     <dbType value="DateTime" /> 
     <layout type="log4net.Layout.RawTimeStampLayout" /> 
     </parameter> 
     <parameter> 
     <parameterName value="@thread" /> 
     <dbType value="String" /> 
     <size value="255" /> 
     <layout type="log4net.Layout.PatternLayout"> 
      <conversionPattern value="%thread" /> 
     </layout> 
     </parameter> 
     <parameter> 
     <parameterName value="@log_level" /> 
     <dbType value="String" /> 
     <size value="50" /> 
     <layout type="log4net.Layout.PatternLayout"> 
      <conversionPattern value="%level" /> 
     </layout> 
     </parameter> 
     <parameter> 
     <parameterName value="@logger" /> 
     <dbType value="String" /> 
     <size value="255" /> 
     <layout type="log4net.Layout.PatternLayout"> 
      <conversionPattern value="%logger" /> 
     </layout> 
     </parameter> 
     <parameter> 
     <parameterName value="@message" /> 
     <dbType value="String" /> 
     <size value="4000" /> 
     <layout type="log4net.Layout.PatternLayout"> 
      <conversionPattern value="%message" /> 
     </layout> 
     </parameter> 
     <parameter> 
     <parameterName value="@exception" /> 
     <dbType value="String" /> 
     <size value="2000" /> 
     <layout type="log4net.Layout.ExceptionLayout" /> 
     </parameter> 
    </appender> 
    <root> 
     <level value="DEBUG"/> 
     <appender-ref ref="AdoNetAppender" /> 
    </root> 
    </log4net> 
</configuration> 

을 : configSections 내 log4net 선언 상단에 얼마나주의하시기 바랍니다

Unhandled Exception: System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section log4net. (D:\local\Temp\jobs\continuous\CommunicationSender\13a4pcai.5fk\CommunicationSender.exe.config line 70) 

누구나 어떤 단서를 가지고 것입니다 여기에? :-) 나는 무엇을 놓치고 있습니까?

는이 같은 코드에서 log4net 초기화하지만이 때문에 구성에 문제가 충돌되지 않습니다 가정

static void Main() 
     { 
      log4net.Config.XmlConfigurator.Configure(); 
      ILog log = log4net.LogManager.GetLogger(typeof(Program)); 
      log.Info("CommunicationSender STARTED! :-)"); 

      var config = new JobHostConfiguration(); 

      if (config.IsDevelopment) 
      { 
       config.UseDevelopmentSettings(); 
      } 

      var host = new JobHost(); 
      // The following code ensures that the WebJob will be running continuously 
      host.RunAndBlock(); 
     } 
+0

아마도이 파일은 인스턴스에서 업데이트되지 않았습니까? 또 다른 방법은 http://logging.apache.org/log4net/release/manual/configuration.html에 따라 xml을 직접로드하는 것입니다. – Artyom

+0

@Artyom 흠 :-) 나는 삭제하고 몇 번 앱을 만들었습니다. 확실히 거기에 내 설정에 어떤 버그가 있지만 솔직히 조금 우둔 해요! 링크를 자세히 읽으십시오. –

+0

Kudu Console에서 수동으로 실행 해보십시오. 동일한 오류가 발생하면 WebJob과 관련이 없다는 것을 알 수 있습니다. –

답변

0

문제는 내 직원 중 하나에 의해 해결되었다. 그는 configSection이 ConnectionString보다 먼저 있어야한다고 지적했다.

주위를 전환 한 후 작동했습니다.

관련 문제