2012-05-04 14 views
2

私はEntLib 4.1を使用しています。私は、ログエントリを異なるカテゴリに関連づけたい。私のカテゴリには、コンテキストの種類(「バッチ」や「オンライン」など)や機能領域(「請求書」や「注文」など)など、さまざまな興味深い情報が反映されます。カテゴリへのEntLibのログ

私はロギングコードを実行しましたが、設定に何か間違っていると思います。私が達成しようとしているのは、カテゴリ「バッチ」に記録されたすべてのエントリを、「バッチ」と呼ばれるイベントログと、アプリケーションログ内のすべてのものにすることです。 (私は手動でこの名前でカスタムイベントログを作成している。)

しかし、代わりにカテゴリバッチでログエントリがアプリケーションログに記録され、各エントリには、次のプリアンブルが含まれます:

 
Message: Tracing to LogSource 'Batch' failed. Processing for other sources will continue. See summary information below for more information. Should this problem persist, stop the service and check the configuration file(s) for possible error(s) in the configuration of the categories and sinks. 

EntLib設定をファイル:

<?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" /> 
    </configSections> 
    <loggingConfiguration name="Logging Application Block" tracingEnabled="true" 
     defaultCategory="APPLICATION" logWarningsWhenNoCategoriesMatch="true"> 
     <listeners> 
      <add source="Project II Logger" formatter="Text Formatter" log="Batch" 
       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="BatchListener" /> 
      <add source="Project II Logger" formatter="Text Formatter" log="Application" 
       machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
       traceOutputOptions="Callstack" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
       name="DefaultListener" /> 
      <add fileName="c:\temp\trace.log" header="----------------------------------------" 
       footer="----------------------------------------" formatter="ExceptionFormatter" 
       listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
       traceOutputOptions="Callstack" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
       name="Exception TraceListener" /> 
     </listeners> 
     <formatters> 
      <add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity: {severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;ErrorMessages: {errorMessages}" 
       type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
       name="ExceptionFormatter" /> 
      <add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity: {severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;ErrorMessages: {errorMessages}" 
       type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
       name="Text Formatter" /> 
     </formatters> 
     <categorySources> 
      <add switchValue="All" name="APPLICATION"> 
       <listeners> 
        <add name="DefaultListener" /> 
       </listeners> 
      </add> 
      <add switchValue="All" name="Batch"> 
       <listeners> 
        <add name="BatchListener" /> 
       </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="DefaultListener" /> 
       </listeners> 
      </errors> 
     </specialSources> 
    </loggingConfiguration> 
</configuration> 
+0

あなたがアプリケーションログに見ているメッセージは、バッチカテゴリーにログインすると、失敗したことを示しています。それはあなたにスタックトレースのような他の情報を与えますか? –

+0

はい、スタックトレースがあります。しかし、私が伐採していた文脈がこの問題と何か関係があったと考える理由はなかったので、私はそれを投稿しませんでした。 –

答えて

0

私の推測では、適切なイベントログやイベントソースをそのログ内に作成していないと思います。

問題は構成ファイルには含まれていません。

batファイルやコンソールアプリケーションから新しいログなどを設定する場合は、必ず管理下で実行してください。

creating log and source win 7

+0

あなたの答えは間違っていますが、私はそれを受け入れます。 EntLibは何かがカテゴリに初めて記録されるときにあなたのためにログとソースを作成するので、そうする必要はありません。しかし、問題は関連していました。同じソースを使用して2つの異なる場所にログを記録しようとしました。これは、Windowsのイベントログモデルでは不正であることが判明しているため、EntLibで非記述的なエラーメッセージだけが原因である可能性があります。 (ソースに反映させるための情報源と、その活動に関する要約情報を集中ログに記録しますが、詳細なトレースは別の場所に記録します)許可されません! –

+0

"Enterprises Library Logging"ソースは自動的に登録されますが、カスタムソース。 – Legends