事件查看器日志记录问题. [英] Event viewer logging Problem.

查看:212
本文介绍了事件查看器日志记录问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友
我正在编写一个示例应用程序,在其中尝试在事件查看器中编写一些消息.
假设其他一些应用程序已经在应用程序和服务日志下创建了类别名称"ZONAL".我想将消息写在"ZONAL"中.
我的代码在这里.

Hi friends
I am writing a sample application in which i am trying to write some messages in event viewer.
Suppose some other application has already created category name "ZONAL" under Applications and services log.I wanty to write my message in "ZONAL".
my code is here.

void eventLogging()
{
 
  // Create the source, if it does not already exist.
  String^ SOURCENAME = "ZONAL";
  String^ LOGNAME = "ZONAL";
  if(!EventLog::SourceExists(SOURCENAME))
  {
    EventLog::CreateEventSource(SOURCENAME, LOGNAME);
  }
  // Create an EventLog instance and assign its source.
   EventLog^ myLog = gcnew EventLog();
   myLog->Source = SOURCENAME;
 
  // Write an informational entry to the event log.    
   myLog->WriteEntry("Writing to event log from console app 2008");

}


int main(array<system::string xmlns:system="#unknown"> ^args)
{
    eventLogging();
    return 0;
}
</system::string>



在我运行时进行编译后,代码消息显示在 Windows日志->应用程序中,但未显示在我想要的类别中.
请告诉我我在某处错了还是我缺少事件记录的任何特定概念.

谢谢



After compiling when i run the code meesage is shown in Windows logs->Application but not in category in which i wanted.
Please tell if i am wrong somewhere or i am lacking any specific concept of event logging.

Thanks

推荐答案

您将日志写在系统日志中,而不是在日志查看器"中.

类别的概念很难理解.请参阅我的代码,在该代码中创建了用于对日志进行分类的包装器;通过这种方法,您可以为产品创建一个单独的文件夹,其中包含一个以上的应用程序.产品的日志将放在同一个单独的文件夹中,但是将对每个应用程序进行分类.最好以这种方式工作,因为如果它们通信,您可以查看来自不同应用程序的日志顺序.

以下是代码:如何在文件夹 [ ^ ].

抱歉,这是C#,但理解它不会有任何问题.
如果您的目标有所不同,那就没关系:仍然只有两个层次结构.

—SA
You write your logs in the system log not in "log viewer".

The concept of category is hard to understand. Please see my code where I created a wrapper designed to categorize the logs; in this approach you can have a separate folder for your product featuring more then one application. The logs for your product will go in the same separate folder, but each application will be categorized. It is good to work this way as you can see the order of logs from different applications if they communicate.

Here is the code: How to create event log under a folder[^].

Sorry, this is C#, but you won''t have any problems understanding it.
If your goal is somewhat different, it does not matter: there are only two levels of hierarchy anyway.

—SA


这篇关于事件查看器日志记录问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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