LoggerException クラス
アセンブリ: Microsoft.Build.Framework (microsoft.build.framework.dll 内)



ビルド イベントに応答する基本 logger を作成する方法を次の例に示します。
using System; using System.IO; using System.Security; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; namespace MyLoggers { // This logger will derive from the Microsoft.Build.Utilities.Logger class, // which provides it with getters and setters for Verbosity and Parameters, // and a default empty Shutdown() implementation. public class BasicFileLogger : Logger { /// <summary> /// Initialize is guaranteed to be called by MSBuild at the start of the build /// before any events are raised. /// </summary> public override void Initialize(IEventSource eventSource) { // The name of the log file should be passed as the first item in the // "parameters" specification in the /logger switch. It is required // to pass a log file to this logger. Other loggers may have zero or more than // one parameters. if (null == Parameters) { throw new LoggerException("Log file was not set."); } string[] parameters = Parameters.Split(';'); string logFile = parameters[0]; if (String.IsNullOrEmpty(logFile)) { throw new LoggerException("Log file was not set."); } if (parameters.Length > 1) { throw new LoggerException("Too many parameters passed."); } try { // Open the file this.streamWriter = new StreamWriter(logFile); } catch (Exception ex) { if ( ex is UnauthorizedAccessException || ex is ArgumentNullException || ex is PathTooLongException || ex is DirectoryNotFoundException || ex is NotSupportedException || ex is ArgumentException || ex is SecurityException || ex is IOException ) { throw new LoggerException("Failed to create log file: " + ex.Message); } else { // Unexpected failure throw; } } // For brevity, we'll only register for certain event types. Loggers can also // register to handle TargetStarted/Finished and other events. eventSource.ProjectStarted += new ProjectStartedEventHandler(eventSource_ProjectStarted); eventSource.TaskStarted += new TaskStartedEventHandler(eventSource_TaskStarted); eventSource.MessageRaised += new BuildMessageEventHandler(eventSource_MessageRaised); eventSource.WarningRaised += new BuildWarningEventHandler(eventSource_WarningRaised); eventSource.ErrorRaised += new BuildErrorEventHandler(eventSource_ErrorRaised); eventSource.ProjectFinished += new ProjectFinishedEventHandler(eventSource_ProjectFinished); } void eventSource_ErrorRaised(object sender, BuildErrorEventArgs e) { // BuildErrorEventArgs adds LineNumber, ColumnNumber, File, amongst other parameters string line = String.Format(": ERROR {0}({1},{2}): ", e.File, e.LineNumber, e.ColumnNumber); WriteLineWithSenderAndMessage(line, e); } void eventSource_WarningRaised(object sender, BuildWarningEventArgs e) { // BuildWarningEventArgs adds LineNumber, ColumnNumber, File, amongst other parameters string line = String.Format(": Warning {0}({1},{2}): ", e.File, e.LineNumber, e.ColumnNumber); WriteLineWithSenderAndMessage(line, e); } void eventSource_MessageRaised(object sender, BuildMessageEventArgs e) { // BuildMessageEventArgs adds Importance to BuildEventArgs // Let's take account of the verbosity setting we've been passed in deciding whether to log the message if ((e.Importance == MessageImportance.High && IsVerbosityAtLeast(LoggerVerbosity.Minimal)) || (e.Importance == MessageImportance.Normal && IsVerbosityAtLeast(LoggerVerbosity.Normal)) || (e.Importance == MessageImportance.Low && IsVerbosityAtLeast(LoggerVerbosity.Detailed)) ) { WriteLineWithSenderAndMessage(String.Empty, e); } } void eventSource_TaskStarted(object sender, TaskStartedEventArgs e) { // TaskStartedEventArgs adds ProjectFile, TaskFile, TaskName // To keep this log clean, this logger will ignore these events. } void eventSource_ProjectStarted(object sender, ProjectStartedEventArgs e) { // ProjectStartedEventArgs adds ProjectFile, TargetNames // Just the regular message string is good enough here, so just display that. WriteLine(String.Empty, e); indent++; } void eventSource_ProjectFinished(object sender, ProjectFinishedEventArgs e) { // The regular message string is good enough here too. indent--; WriteLine(String.Empty, e); } /// <summary> /// Write a line to the log, adding the SenderName and Message /// (these parameters are on all MSBuild event argument objects) /// </summary> private void WriteLineWithSenderAndMessage(string line, BuildEventArgs e) { if (0 == String.Compare(e.SenderName, "MSBuild", true /*ignore case*/)) { // Well, if the sender name is MSBuild, let's leave it out for prettiness WriteLine(line, e); } else { WriteLine(e.SenderName + ": " + line, e); } } /// <summary> /// Just write a line to the log /// </summary> private void WriteLine(string line, BuildEventArgs e) { for (int i = indent; i > 0; i--) { streamWriter.Write("\t"); } streamWriter.WriteLine(line + e.Message); } /// <summary> /// Shutdown() is guaranteed to be called by MSBuild at the end of the build, after all /// events have been raised. /// </summary> public override void Shutdown() { // Done logging, let go of the file streamWriter.Close(); } private StreamWriter streamWriter; private int indent; } }

System.Exception
Microsoft.Build.Framework.LoggerException


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


LoggerException コンストラクタ ()
アセンブリ: Microsoft.Build.Framework (microsoft.build.framework.dll 内)



Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


LoggerException コンストラクタ

名前 | 説明 |
---|---|
LoggerException () | LoggerException クラスの新しいインスタンスを初期化します。 |
LoggerException (String) | 値を指定して、LoggerException クラスの新しいインスタンスを初期化します。 |
LoggerException (SerializationInfo, StreamingContext) | 値を指定して、LoggerException クラスの新しいインスタンスを初期化します。 |
LoggerException (String, Exception) | 値を指定して、LoggerException クラスの新しいインスタンスを初期化します。 |
LoggerException (String, Exception, String, String) | 値を指定して、LoggerException クラスの新しいインスタンスを初期化します。 |

LoggerException コンストラクタ (String)
アセンブリ: Microsoft.Build.Framework (microsoft.build.framework.dll 内)


ビルド イベントに応答する基本 logger を作成する方法を次の例に示します。
using System; using System.IO; using System.Security; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; namespace MyLoggers { // This logger will derive from the Microsoft.Build.Utilities.Logger class, // which provides it with getters and setters for Verbosity and Parameters, // and a default empty Shutdown() implementation. public class BasicFileLogger : Logger { /// <summary> /// Initialize is guaranteed to be called by MSBuild at the start of the build /// before any events are raised. /// </summary> public override void Initialize(IEventSource eventSource) { // The name of the log file should be passed as the first item in the // "parameters" specification in the /logger switch. It is required // to pass a log file to this logger. Other loggers may have zero or more than // one parameters. if (null == Parameters) { throw new LoggerException("Log file was not set."); } string[] parameters = Parameters.Split(';'); string logFile = parameters[0]; if (String.IsNullOrEmpty(logFile)) { throw new LoggerException("Log file was not set."); } if (parameters.Length > 1) { throw new LoggerException("Too many parameters passed."); } try { // Open the file this.streamWriter = new StreamWriter(logFile); } catch (Exception ex) { if ( ex is UnauthorizedAccessException || ex is ArgumentNullException || ex is PathTooLongException || ex is DirectoryNotFoundException || ex is NotSupportedException || ex is ArgumentException || ex is SecurityException || ex is IOException ) { throw new LoggerException("Failed to create log file: " + ex.Message); } else { // Unexpected failure throw; } } // For brevity, we'll only register for certain event types. Loggers can also // register to handle TargetStarted/Finished and other events. eventSource.ProjectStarted += new ProjectStartedEventHandler(eventSource_ProjectStarted); eventSource.TaskStarted += new TaskStartedEventHandler(eventSource_TaskStarted); eventSource.MessageRaised += new BuildMessageEventHandler(eventSource_MessageRaised); eventSource.WarningRaised += new BuildWarningEventHandler(eventSource_WarningRaised); eventSource.ErrorRaised += new BuildErrorEventHandler(eventSource_ErrorRaised); eventSource.ProjectFinished += new ProjectFinishedEventHandler(eventSource_ProjectFinished); } void eventSource_ErrorRaised(object sender, BuildErrorEventArgs e) { // BuildErrorEventArgs adds LineNumber, ColumnNumber, File, amongst other parameters string line = String.Format(": ERROR {0}({1},{2}): ", e.File, e.LineNumber, e.ColumnNumber); WriteLineWithSenderAndMessage(line, e); } void eventSource_WarningRaised(object sender, BuildWarningEventArgs e) { // BuildWarningEventArgs adds LineNumber, ColumnNumber, File, amongst other parameters string line = String.Format(": Warning {0}({1},{2}): ", e.File, e.LineNumber, e.ColumnNumber); WriteLineWithSenderAndMessage(line, e); } void eventSource_MessageRaised(object sender, BuildMessageEventArgs e) { // BuildMessageEventArgs adds Importance to BuildEventArgs // Let's take account of the verbosity setting we've been passed in deciding whether to log the message if ((e.Importance == MessageImportance.High && IsVerbosityAtLeast(LoggerVerbosity.Minimal)) || (e.Importance == MessageImportance.Normal && IsVerbosityAtLeast(LoggerVerbosity.Normal)) || (e.Importance == MessageImportance.Low && IsVerbosityAtLeast(LoggerVerbosity.Detailed)) ) { WriteLineWithSenderAndMessage(String.Empty, e); } } void eventSource_TaskStarted(object sender, TaskStartedEventArgs e) { // TaskStartedEventArgs adds ProjectFile, TaskFile, TaskName // To keep this log clean, this logger will ignore these events. } void eventSource_ProjectStarted(object sender, ProjectStartedEventArgs e) { // ProjectStartedEventArgs adds ProjectFile, TargetNames // Just the regular message string is good enough here, so just display that. WriteLine(String.Empty, e); indent++; } void eventSource_ProjectFinished(object sender, ProjectFinishedEventArgs e) { // The regular message string is good enough here too. indent--; WriteLine(String.Empty, e); } /// <summary> /// Write a line to the log, adding the SenderName and Message /// (these parameters are on all MSBuild event argument objects) /// </summary> private void WriteLineWithSenderAndMessage(string line, BuildEventArgs e) { if (0 == String.Compare(e.SenderName, "MSBuild", true /*ignore case*/)) { // Well, if the sender name is MSBuild, let's leave it out for prettiness WriteLine(line, e); } else { WriteLine(e.SenderName + ": " + line, e); } } /// <summary> /// Just write a line to the log /// </summary> private void WriteLine(string line, BuildEventArgs e) { for (int i = indent; i > 0; i--) { streamWriter.Write("\t"); } streamWriter.WriteLine(line + e.Message); } /// <summary> /// Shutdown() is guaranteed to be called by MSBuild at the end of the build, after all /// events have been raised. /// </summary> public override void Shutdown() { // Done logging, let go of the file streamWriter.Close(); } private StreamWriter streamWriter; private int indent; } }


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


LoggerException コンストラクタ (SerializationInfo, StreamingContext)
アセンブリ: Microsoft.Build.Framework (microsoft.build.framework.dll 内)

Dim info As SerializationInfo Dim context As StreamingContext Dim instance As New LoggerException(info, context)


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


LoggerException コンストラクタ (String, Exception)
アセンブリ: Microsoft.Build.Framework (microsoft.build.framework.dll 内)

Dim message As String Dim innerException As Exception Dim instance As New LoggerException(message, innerException)


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


LoggerException コンストラクタ (String, Exception, String, String)
アセンブリ: Microsoft.Build.Framework (microsoft.build.framework.dll 内)

Public Sub New ( _ message As String, _ innerException As Exception, _ errorCode As String, _ helpKeyword As String _ )
Dim message As String Dim innerException As Exception Dim errorCode As String Dim helpKeyword As String Dim instance As New LoggerException(message, innerException, errorCode, helpKeyword)
public LoggerException ( string message, Exception innerException, string errorCode, string helpKeyword )
public: LoggerException ( String^ message, Exception^ innerException, String^ errorCode, String^ helpKeyword )
public LoggerException ( String message, Exception innerException, String errorCode, String helpKeyword )
public function LoggerException ( message : String, innerException : Exception, errorCode : String, helpKeyword : String )


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


LoggerException プロパティ

名前 | 説明 | |
---|---|---|
![]() | Data | 例外に関する追加のユーザー定義情報を提供するキー/値ペアのコレクションを取得します。 ( Exception から継承されます。) |
![]() | ErrorCode | この例外のメッセージに関連付けられたエラー コードを取得します。 |
![]() | HelpKeyword | このエラーに関連付けられている F1 ヘルプのキーワードを取得します。 |
![]() | HelpLink | 例外に関連付けられているヘルプ ファイルへのリンクを取得または設定します。 ( Exception から継承されます。) |
![]() | InnerException | 現在の例外を発生させた Exception インスタンスを取得します。 ( Exception から継承されます。) |
![]() | Message | 現在の例外を説明するメッセージを取得します。 ( Exception から継承されます。) |
![]() | Source | エラーの原因となったアプリケーションまたはオブジェクトの名前を取得または設定します。 ( Exception から継承されます。) |
![]() | StackTrace | 現在の例外がスローされたときにコール スタックにあったフレームの文字列形式を取得します。 ( Exception から継承されます。) |
![]() | TargetSite | 現在の例外をスローするメソッドを取得します。 ( Exception から継承されます。) |


LoggerException メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetBaseException | 派生クラスでオーバーライドされた場合、それ以後に発生する 1 つ以上の例外の主要な原因である Exception を返します。 ( Exception から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetObjectData | オーバーライドされます。 例外に関する情報を使用して、SerializationInfo を設定します。 |
![]() | GetType | 現在のインスタンスのランタイム型を取得します。 ( Exception から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の例外の文字列形式を作成して返します。 ( Exception から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

LoggerException メンバ
logger によって、ビルドを明示的な方法で強制的に停止できるようにします。
LoggerException データ型で公開されるメンバを以下の表に示します。



名前 | 説明 | |
---|---|---|
![]() | Data | 例外に関する追加のユーザー定義情報を提供するキー/値ペアのコレクションを取得します。(Exception から継承されます。) |
![]() | ErrorCode | この例外のメッセージに関連付けられたエラー コードを取得します。 |
![]() | HelpKeyword | このエラーに関連付けられている F1 ヘルプのキーワードを取得します。 |
![]() | HelpLink | 例外に関連付けられているヘルプ ファイルへのリンクを取得または設定します。(Exception から継承されます。) |
![]() | InnerException | 現在の例外を発生させた Exception インスタンスを取得します。(Exception から継承されます。) |
![]() | Message | 現在の例外を説明するメッセージを取得します。(Exception から継承されます。) |
![]() | Source | エラーの原因となったアプリケーションまたはオブジェクトの名前を取得または設定します。(Exception から継承されます。) |
![]() | StackTrace | 現在の例外がスローされたときにコール スタックにあったフレームの文字列形式を取得します。(Exception から継承されます。) |
![]() | TargetSite | 現在の例外をスローするメソッドを取得します。(Exception から継承されます。) |


名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetBaseException | 派生クラスでオーバーライドされた場合、それ以後に発生する 1 つ以上の例外の主要な原因である Exception を返します。 (Exception から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetObjectData | オーバーライドされます。 例外に関する情報を使用して、SerializationInfo を設定します。 |
![]() | GetType | 現在のインスタンスのランタイム型を取得します。 (Exception から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の例外の文字列形式を作成して返します。 (Exception から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

Weblioに収録されているすべての辞書からLoggerExceptionを検索する場合は、下記のリンクをクリックしてください。

- LoggerExceptionのページへのリンク