在文件夹下创建事件日志(应用程序和服务日志) [英] Create event log under folder (applications and services logs)

查看:130
本文介绍了在文件夹下创建事件日志(应用程序和服务日志)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,



我在事件查看器上创建事件日志时遇到问题。

问题如下:

我正在使用此代码在事件查看器中创建事件日志。

  private   static   void  WriteEventLogEntry( string  message)
{
尝试
{
尝试 { if (!EventLog.SourceExists( COO )){EventLog.CreateEventSource( COO COOLog); }
catch (例外){}
EventLog Log = new EventLog( );
Log.Source = COOLog;
Log.WriteEntry(message,EventLogEntryType.Error, 0 );
}
catch (例外情况){}
}





实际上,我的电脑上的一切都做得非常好。

但是在发布到服务器之后,我遇到了一个必须是管理员的许可问题。



我以为我可以通过使用命令提示符或其他东西手动创建这个文件,但我不能这样做。



所以,现在任何人都可以帮助我如何通过代码解决此权限问题或通过命令提示符手动添加事件日志到(应用程序和服务日志)文件夹?



谢谢提前。



我尝试了什么:



我试过这个通过命令提示符添加它,但是日志是在应用程序日志中创建的(应用程序和服务日志)文件夹。



eventcreate / ID 1 / L APPLICATION / T INFORMATION / SO COO / DCOOLog

解决方案

创建事件源需要管理员权限。这通常是在安装时由安装人员完成的,而不是在应用程序运行时完成的。





您只能创建一个一次一个日志中的事件。如果您希望事件显示在多个日志中,则必须为每个日志创建单独的事件。


Dears,

I 've a problem with creating event log on event viewer.
The issue is as following:
I am using this code to create event log in event viewer.

private static void WriteEventLogEntry(string message)
        {
            try
            {
                try { if (!EventLog.SourceExists("COO")) { EventLog.CreateEventSource("COO", "COOLog"); } }
                catch (Exception) { }
                EventLog Log = new EventLog();
                Log.Source = "COOLog";
                Log.WriteEntry(message, EventLogEntryType.Error, 0);
            }
            catch (Exception ex) { }
        }



Actually, Everything is done very well on my PC.
but after publishing to server, i faced a permission issue that i must be administrator.

I thought i could create this file manually by using command prompt or something else but i couldn't do that.

So, now can any one help me how to solve this permission issue by code or add event log to (Applications and services logs) Folder manually by command prompt?

Thanks in advance.

What I have tried:

I have tried this line to add it by command prompt, but the log is created in Application logs not in (Applications and services logs) Folder.

eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO COO /D "COOLog"

解决方案

Creating an event source requires administrator permissions. This is something that is normally done at install time, by your installer, not at application run time.


You can only create an event in one log at a time. If you want an event to show up in multiple logs you have to create separate events for each log.


这篇关于在文件夹下创建事件日志(应用程序和服务日志)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆