オープンソースのロギングフレームワークExceptionlessチュートリアル

Exceptionlessは、ロギングフレームワークである、それはインストールして使いやすい管理インターフェイスを提供し、無料、オープンソースです。ログストレージとしてElasticSearchを使用してExceptionLess底は、当社のシステムインテグレーションを容易にするため、高速で、豊富なクエリAPIを提供します。この記事ではExceptionLessの一般的な使用法を説明します。

インストールExceptionLess

ExceptionLess公式サイトではベースドッカーの民営化の展開を提供し、我々は仕方公式サイトでテスト環境をインストールすることができます。

  1. 公式サイトのgithubのパッケージの最新版をダウンロードして、アドレス:https://github.com/exceptionless/Exceptionless/releases
  2. 実行、解凍して、解凍したディレクトリを入力しますdocker-compose up -dExceptionlessすでにアップしてローカルで実行している、実行が完了すると、バックグラウンドで複数の容器を起動するコマンドを。私たちは、船がKitematicで実行して見ることができます
  3. 5000ポートの公式ウェブサイトに従ってランディングページであるが、現実には5000がAPIであるということです、5100は、ランディングページであるので、我々はオープンにhttp:// localhostを:5100ログインページを入力します。注意:これは、バージョンと関連している可能性があり、使用時にポートマッピングドッキングウィンドウを参照してください。

以上の工程により、ローカル環境で良いテストを構築します。私たちは、Redisの、elasticsearch、kibana、Exceptionless仕事、Exceptionlessアピ、Excetpionless UIある6隻、合計の開始を見始めることができます。

クイックスタート

ユーザー、組織やプロジェクトを作成するには良い、最初の訪問Exceptionless UIを構築するためのテスト環境の後。プロジェクトが作成されたときに続いて、ExceptionlessたちはExceptionlessクライアントを使用する方法を導くために、クライアントの設定ページにジャンプします。私たちは、ページの指導を通じて、クライアントの設定を完了するために、クライアント自身のニーズを使用するように選択することができます。

次のようにブートページは次のようになります。

画像

このように、私たちは、プロジェクト.NETプラットフォーム、設定JSプロジェクトを完了することができます。

クライアントAPI:https://github.com/exceptionless/Exceptionless.Net/wiki

構成された後、我々は、例えば(コードは公式サイトから来ている)ログインできます。

// Import the exceptionless namespace.
using Exceptionless;

// Submit logs
ExceptionlessClient.Default.SubmitLog("Logging made easy");

// You can also specify the log source and log level.
// We recommend specifying one of the following log levels: Trace, Debug, Info, Warn, Error
ExceptionlessClient.Default.SubmitLog(typeof(Program).FullName, "This is so easy", "Info");
ExceptionlessClient.Default.CreateLog(typeof(Program).FullName, "This is so easy", "Info").AddTags("Exceptionless").Submit();

// Submit feature usages
ExceptionlessClient.Default.SubmitFeatureUsage("MyFeature");
ExceptionlessClient.Default.CreateFeatureUsage("MyFeature").AddTags("Exceptionless").Submit();

// Submit a 404
ExceptionlessClient.Default.SubmitNotFound("/somepage");
ExceptionlessClient.Default.CreateNotFound("/somepage").AddTags("Exceptionless").Submit();

// Submit a custom event type
ExceptionlessClient.Default.SubmitEvent(new Event { Message = "Low Fuel", Type = "racecar", Source = "Fuel System" });

特長

次のタイプでExceptionlessイベント:

  • ログメッセージ:ログレコードは、任意のテキストコンテンツすることができ
  • インターフェース呼び出しの場合、たとえば記録の利用機能、のような:特性を使用します
  • 異常:異常な記録情報
  • リンク切れ:記録ページが存在しない場合にアクセスされます

外部記録されたコンテンツに加えて、Exceptionlessはまた、イベントタグのサポートを追加し、追加的なデータは、ユーザの操作等について説明したが、例えば、(公式サイトからのコード)。

try {
    throw new ApplicationException("Unable to create order from quote.");
} catch (Exception ex) {
    ex.ToExceptionless()
        // Set the reference id of the event so we can search for it later (reference:id).
        // This will automatically be populated if you call ExceptionlessClient.Default.Configuration.UseReferenceIds();
        .SetReferenceId(Guid.NewGuid().ToString("N"))
        // Add the order object but exclude the credit number property.
        .AddObject(order, "Order", excludedPropertyNames: new [] { "CreditCardNumber" }, maxDepth: 2)
        // Set the quote number.
        .SetProperty("Quote", 123)
        // Add an order tag.
        .AddTags("Order")
        // Mark critical.
        .MarkAsCritical()
        // Set the coordinates of the end user.
        .SetGeo(43.595089, -88.444602)
        // Set the user id that is in our system and provide a friendly name.
        .SetUserIdentity(user.Id, user.FullName)
        // Set the users description of the error.
        .SetUserDescription(user.EmailAddress, "I tried creating an order from my saved quote.")
        // Submit the event.
        .Submit();
}

NLog、log4netの集成

公式サポートNLog、log4netのは、単にロギング・コンポーネントをすることができ、適切なコンフィギュレーション・ファイルを追加し、サポートを統合しました。log4netの例には:

支持アセンブリを追加することで起動します。

Install-Package Exceptionless.Log4net

そして、log4netのプロファイルで(公式サイトからコード)を設定します。

<log4net>
<appender name="exceptionless" type="Exceptionless.Log4net.ExceptionlessAppender,Exceptionless.Log4net">
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%-4timestamp [%thread] %-5level %logger %ndc - %message%newline"/>
  </layout>
</appender>

<root>
  <level value="DEBUG"/>
  <appender-ref ref="exceptionless"/>
</root>
</log4net>

APIインタフェース

リッチクライアントの機能に加えて、ExceptionlessもAPIのサポートの番号を提供し、APIは、ポート5000にアクセスすることができます。住所:HTTP:// localhostを:5000 /ドキュメント/ index.htmlを、ショット次のとおりです

画像

これらのインタフェースを通じて、私たちは、このようなユーザー認証、プロジェクト管理、ログのクエリや他の操作など、よりカスタム操作を、達成することができます。

参考資料

おすすめ

転載: www.cnblogs.com/youring2/p/11546485.html
おすすめ