EventLog.DeleteEventSource 메서드

정의

이벤트 로그에서 애플리케이션의 이벤트 소스 등록을 제거합니다.

오버로드

DeleteEventSource(String)

로컬 컴퓨터의 이벤트 로그에서 이벤트 소스 등록을 제거합니다.

DeleteEventSource(String, String)

지정한 컴퓨터에서 애플리케이션의 이벤트 소스 등록을 제거합니다.

DeleteEventSource(String)

Source:
EventLog.cs
Source:
EventLog.cs
Source:
EventLog.cs

로컬 컴퓨터의 이벤트 로그에서 이벤트 소스 등록을 제거합니다.

public:
 static void DeleteEventSource(System::String ^ source);
public static void DeleteEventSource (string source);
static member DeleteEventSource : string -> unit
Public Shared Sub DeleteEventSource (source As String)

매개 변수

source
String

이벤트 로그 시스템에 등록된 애플리케이션 이름입니다.

예외

source 매개 변수가 로컬 컴퓨터의 레지스트리에 없는 경우

또는

이벤트 로그의 레지스트리 키에 대한 쓰기 권한이 없는 경우

예제

다음 예제에서는 로컬 컴퓨터에서 원본을 삭제합니다. 이 예제에서는 원본에서 로그를 확인한 다음 로그를 삭제합니다.

참고

둘 이상의 원본이 이벤트 로그에 쓸 수 있습니다. 사용자 지정 로그를 삭제하기 전에 해당 로그에 쓰는 다른 원본이 없는지 확인합니다.

#using <System.dll>

using namespace System;
using namespace System::Diagnostics;
using namespace System::Threading;
int main()
{
   String^ logName;
   if ( EventLog::SourceExists( "MySource" ) )
   {
      
      // Find the log associated with this source.    
      logName = EventLog::LogNameFromSourceName( "MySource", "." );
      // Make sure the source is in the log we believe it to be in
      if (logName != "MyLog")
          return -1;
      // Delete the source and the log.
      EventLog::DeleteEventSource( "MySource" );
      EventLog::Delete( logName );
      Console::WriteLine( "{0} deleted.", logName );
   }
   else
        {
            // Create the event source to make next try successful.
            EventLog::CreateEventSource("MySource", "MyLog");
        }
}
using System;
using System.Diagnostics;
using System.Threading;

class MySample1
{
    public static void Main()
    {
        string logName;

        if (EventLog.SourceExists("MySource"))
        {
            // Find the log associated with this source.
            logName = EventLog.LogNameFromSourceName("MySource", ".");
            // Make sure the source is in the log we believe it to be in.
            if (logName != "MyLog")
                return;
            // Delete the source and the log.
            EventLog.DeleteEventSource("MySource");
            EventLog.Delete(logName);

            Console.WriteLine(logName + " deleted.");
        }
        else
        {
            // Create the event source to make next try successful.
            EventLog.CreateEventSource("MySource", "MyLog");
        }
    }
}
Option Explicit On
Option Strict On

Imports System.Diagnostics
Imports System.Threading

Class MySample
    Public Shared Sub Main()
        Dim logName As String

        If EventLog.SourceExists("MySource") Then
            ' Find the log associated with this source.    
            logName = EventLog.LogNameFromSourceName("MySource", ".")
            ' Make sure the source is in the log we believe it to be in
            If (logName <> "MyLog") Then
                Return
            End If
            ' Delete the source and the log.
            EventLog.DeleteEventSource("MySource")
            EventLog.Delete(logName)

            Console.WriteLine((logName & " deleted."))
        Else
            ' Create the event source to make next try successful.
            EventLog.CreateEventSource("MySource", "MyLog")
        End If
    End Sub
End Class

설명

이 메서드를 사용하여 로컬 컴퓨터에서 의 Source 등록을 제거합니다. DeleteEventSource 로컬 컴퓨터의 레지스트리에 액세스 하 고 이벤트의 유효한 소스로 애플리케이션의 등록을 제거 합니다.

더 이상 해당 로그에 항목을 쓸 필요가 없는 경우 구성 요소를 유효한 이벤트 원본으로 제거할 수 있습니다. 예를 들어 구성 요소를 한 로그에서 다른 로그로 변경해야 하는 경우 이 작업을 수행할 수 있습니다. 원본은 한 번에 하나의 로그에만 등록할 수 있으므로 로그를 변경하려면 현재 등록을 제거해야 합니다.

DeleteEventSource 는 로그에 등록된 원본만 제거합니다. 로그 자체를 제거하려면 를 호출합니다 Delete. 로그 항목만 삭제하려면 를 호출 Clear합니다. DeleteDeleteEventSourcestatic 메서드이므로 클래스 자체에서 호출할 수 있습니다. 두 메서드 중 하나를 호출하는 의 instance EventLog 만들 필요는 없습니다.

호출을 통해 로그를 삭제하면 해당 로그에 Delete 등록된 원본이 자동으로 삭제됩니다. 이 작동 하지 않는 해당 로그를 사용 하 여 다른 애플리케이션을 만들 수 있습니다.

참고

원본이 이미 로그에 매핑되어 새 로그에 다시 매핑된 경우 변경 내용을 적용하려면 컴퓨터를 다시 시작해야 합니다.

추가 정보

적용 대상

DeleteEventSource(String, String)

Source:
EventLog.cs
Source:
EventLog.cs
Source:
EventLog.cs

지정한 컴퓨터에서 애플리케이션의 이벤트 소스 등록을 제거합니다.

public:
 static void DeleteEventSource(System::String ^ source, System::String ^ machineName);
public static void DeleteEventSource (string source, string machineName);
static member DeleteEventSource : string * string -> unit
Public Shared Sub DeleteEventSource (source As String, machineName As String)

매개 변수

source
String

이벤트 로그 시스템에 등록된 애플리케이션 이름입니다.

machineName
String

등록을 제거할 컴퓨터의 이름입니다. 로컬 컴퓨터의 경우에는 "."입니다.

예외

machineName 매개 변수가 잘못되었습니다.

또는

source 매개 변수가 지정한 컴퓨터의 레지스트리에 없는 경우

또는

이벤트 로그의 레지스트리 키에 대한 쓰기 권한이 없는 경우

레지스트리에서 source에 대한 부모 레지스트리 키에 같은 이름의 하위 키가 없기 때문에 source를 삭제할 수 없는 경우

예제

다음 예제에서는 지정된 컴퓨터에서 원본을 삭제합니다. 이 예제에서는 원본에서 로그를 확인한 다음 로그를 삭제합니다.

참고

둘 이상의 원본이 이벤트 로그에 쓸 수 있습니다. 사용자 지정 로그를 삭제하기 전에 해당 로그에 쓰는 다른 원본이 없는지 확인합니다.

#using <System.dll>

using namespace System;
using namespace System::Diagnostics;
using namespace System::Threading;
int main()
{
   String^ logName;
   if ( EventLog::SourceExists( "MySource", "MyMachine") )
   {
      
      // Find the log associated with this source.    
      logName = EventLog::LogNameFromSourceName( "MySource", "MyMachine" );
      // Make sure the source is in the log we believe it to be in
      if (logName != "MyLog")
          return -1;
      // Delete the source and the log.
      EventLog::DeleteEventSource( "MySource", "MyMachine" );
      EventLog::Delete( logName, "MyMachine" );
      Console::WriteLine( "{0} deleted.", logName );
   }
   else
        {
            // Create the event source to make next try successful.
            EventSourceCreationData^ mySourceData = gcnew EventSourceCreationData("MySource", "MyLog");
            mySourceData->MachineName = "MyMachine";
            EventLog::CreateEventSource(mySourceData);
        }
}
using System;
using System.Diagnostics;
using System.Threading;

class MySample
{
    public static void Main()
    {
        string logName;

        if (EventLog.SourceExists("MySource", "MyMachine"))
        {
            // Find the log associated with this source.
            logName = EventLog.LogNameFromSourceName("MySource", "MyMachine");
            // Make sure the source is in the log we believe it to be in.
            if (logName != "MyLog")
                return;
            // Delete the source and the log.
            EventLog.DeleteEventSource("MySource", "MyMachine");
            EventLog.Delete(logName, "MyMachine");

            Console.WriteLine(logName + " deleted.");
        }
        else
        {
            // Create the event source to make next try successful.
            EventSourceCreationData mySourceData = new EventSourceCreationData("MySource", "MyLog");
            mySourceData.MachineName = "MyMachine";
            EventLog.CreateEventSource(mySourceData);
        }
    }
}
Option Explicit On
Option Strict On

Imports System.Diagnostics
Imports System.Threading

Class MySample
    Public Shared Sub Main()
        Dim logName As String

        If EventLog.SourceExists("MySource", "MyMachine") Then
            ' Find the log associated with this source.    
            logName = EventLog.LogNameFromSourceName("MySource", "MyMachine")
            ' Make sure the source is in the log we believe it to be in
            If (logName <> "MyLog") Then
                Return
            End If
            ' Delete the source and the log.
            EventLog.DeleteEventSource("MySource", "MyMachine")
            EventLog.Delete(logName, "MyMachine")

            Console.WriteLine((logName & " deleted."))
        Else
            ' Create the event source to make next try successful.
            Dim mySourceData As New EventSourceCreationData("MySource", "MyLog")
            mySourceData.MachineName = "MyMachine"
            EventLog.CreateEventSource(mySourceData)
        End If
    End Sub
End Class

설명

이 오버로드를 사용하여 원격 컴퓨터에서 의 Source 등록을 제거합니다. DeleteEventSource 지정 된 컴퓨터의 레지스트리에 액세스 machineName 이벤트의 유효한 소스로 애플리케이션의 등록을 제거 합니다.

더 이상 해당 로그에 항목을 쓸 필요가 없는 경우 구성 요소를 유효한 이벤트 원본으로 제거할 수 있습니다. 예를 들어 구성 요소를 한 로그에서 다른 로그로 변경해야 하는 경우 이 작업을 수행할 수 있습니다. 원본은 한 번에 하나의 로그에만 등록할 수 있으므로 로그를 변경하려면 현재 등록을 제거해야 합니다.

DeleteEventSource 는 로그에 등록된 원본만 제거합니다. 로그 자체를 제거하려면 를 호출합니다 Delete. 로그 항목만 삭제하려면 를 호출 Clear합니다. DeleteDeleteEventSourcestatic 메서드이므로 클래스 자체에서 호출할 수 있습니다. 두 메서드 중 하나를 호출하는 의 instance EventLog 만들 필요는 없습니다.

호출을 통해 로그를 삭제하면 해당 로그에 Delete 등록된 원본이 자동으로 삭제됩니다. 이 작동 하지 않는 해당 로그를 사용 하 여 다른 애플리케이션을 만들 수 있습니다.

참고

원본이 이미 로그에 매핑되어 새 로그에 다시 매핑된 경우 변경 내용을 적용하려면 컴퓨터를 다시 시작해야 합니다.

추가 정보

적용 대상