using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Custom_Event_Log_App
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button_EventAndSourceLog_Click(object sender, EventArgs e)
{
if (textBox_LogName.Text != string.Empty && textBox_LogSource.Text != string.Empty)
{
System.Diagnostics.EventLog.CreateEventSource(textBox_LogSource.Text, textBox_LogName.Text);
MessageBox.Show("Event Log and Source Created");
}
else
{
MessageBox.Show("Event Log and Source is Required...!");
}
}
}
}
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application’s trust level in the configuration file.
Exception Details: System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security
Stack Trace:
[SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.]