Giter Club home page Giter Club logo

inasync.diagnostics.erroreventlogtracelistener's Introduction

InAsync.Diagnostics.ErrorEventLogTraceListener

ErrorEventLogTraceListener はトレース情報のうち、エラーイベントのみをイベントログへ転送する .NET トレースリスナーです。

Description

.NET Framework にはトレース情報をイベントログへ記録するトレースリスナーとして System.Diagnostics.EventLogTraceListener が用意されていますが、 このリスナーに対して Trace.TraceError メソッドを使用すると、イベント ID が常に 0 となってしまいます。

ErrorEventLogTraceListener はエラーイベントをハンドリングし、任意のイベント ID を使用してイベントログに書き込みます。

※ レガシーな Trace クラスの為のトレースリスナーです。TraceSource を使用できる場合はそちらが推奨されます。

Usage

ソリューションをビルドして出来た InAsync.Diagnostics.ErrorEventLogTraceListener.dll を、トレースが実装されている実行ファイルと同じフォルダに配置します。

config ファイルに下記のような記載を行います。

e.g.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  ...
  <system.diagnostics>
    <trace>
      <listeners>
        <add name="ErrorEventLog"
             type="InAsync.Diagnostics.ErrorEventLogTraceListener,InAsync.Diagnostics.ErrorEventLogTraceListener"
             initializeData=".NET Runtime"
             eventId="1026"
        />
      </listeners>
    </trace>
  </system.diagnostics>
  ...
</configuration>

対象の実行ファイルでエラータイプのトレース情報を出力すれば、指定されたイベント ID でイベントログに書き込まれます。

Trace.TraceError(errorMessage);

Licence

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.