在 Windows 中,应用程序事件日志中有哪些默认事件源可用?

发布于 2024-11-29 07:40:19 字数 551 浏览 1 评论 0原文

简短版本:

事件源“应用程序”和“应用程序错误”是否始终包含在应用程序事件日志中?它们在新安装的 Windows XP、Vista 和 Windows 7 上可用吗?使用它们而不是创建我自己的源代码真的很糟糕吗(对我来说这是不可能的)?

长版

我有一个 ClickOnce 应用程序,可供在其计算机上没有管理权限的用户使用。

当我尝试写入应用程序事件日志时,出现安全异常。 (Windows 事件日志基础结构试图为我创建一个新的事件源,但发生了安全违规。)

因此我想尝试重用现有的事件源。我在应用程序事件日志中发现了两个“听起来很笼统”的来源。这些是否始终是 Windows 安装的一部分,并且会做出合理的选择?

  • 应用
  • 应用程序错误

    我确信这是不受欢迎的,因为我应该使用自己的事件源来区分我的应用程序。但这是针对罕见的致命错误,这些错误应该由我的代码记录在其他地方。我只是想要一个非常容易的地方来在客户端计算机上找到它们,以防万一出现问题......

  • Short Version:

    Are the event sources "Application" and "Application Error" always included in the Application Event Log? Are they available on new installations of Windows XP, Vista and Windows 7? Would it be really bad to use them instead of creating my own source (an impossibility for me)?

    Long Version:

    I have a ClickOnce application that is used by users without administrative privileges on their machines.

    When I try to write to the Appliction Event Log, I get a security exception. (The Windows event logging infrastructure is trying to create me a new event source, and gets a security violation.)

    So I would like to try reusing an existing event source. I have found a only two"generic-sounding" sources in the Application Event Log. Are these always part of a Windows installation, and would make a reasonable choice?

  • Application
  • Application Error

    I am sure this is frowned upon, as I should distinguish my application using its own event source. But this is for infrequent fatal errors, which should be getting logged elsewhere by my code. I just want a really easy place to find them on a client machine in case it all goes wrong...

  • 如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

    扫码二维码加入Web技术交流群

    发布评论

    需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

    评论(1

    倚栏听风 2024-12-06 07:40:19

    当我尝试写入应用程序事件日志时,出现安全异常。 (Windows 事件日志基础结构试图为我创建一个新的事件源,但出现了安全违规。)

    我刚刚在这里回答了这个问题:在 ClickOnce 应用程序中使用 EventLog

    所以我想尝试重用现有的事件源。我在应用程序事件日志中发现了两个“听起来很笼统”的来源。这些始终是 Windows 安装的一部分,并且会做出合理的选择吗?

    这样做确实不明智。现有事件源将由 Windows 应用程序或第三方应用程序使用。如果其中任何一个被删除,或者被服务包或补丁之类的东西改变,你的程序将会崩溃,除非你已经实现了异常处理来优雅地处理异常,但这样你就不会记录任何事件。

    另请考虑将应用程序移植到下一版本的 Windows 可能需要做的工作。我建议你为自己的背做一根棍子。

    在我链接的答案中,我建议处理问题的最佳方法是使用管理员权限安装应用程序,安装程序创建源,或者创建一个简单的应用程序,使用管理员角色有效地执行相同的操作。

    我唯一可以建议的是始终在管理模式下运行您的应用程序。

    When I try to write to the Appliction Event Log, I get a security exception. (The Windows event logging infrastructure is trying to create me a new event source, and gets a security violation.)

    I have just answered this here: Using EventLog in ClickOnce application

    So I would like to try reusing an existing event source. I have found a only two"generic-sounding" sources in the Application Event Log. Are these always part of a Windows installation, and would make a reasonable choice?

    It's really not wise to do this. Existing event sources will be used by either Windows applications, or by third party applications. If any of those are removed, or changed by something like a service pack or patch, your program will crash unless you have implemented exception handling to handle the exception gracefully, but then you wont have any event logging.

    Also consider the work you may have to do to port your app to the next version of Windows. I suggest you will be making a rod for your own back.

    In the answer I linked to, I suggested the best way to handle the problem, is to install your application using admin privs with the installer creating the source, or by creating a simple app that effectively does the same using the admin role.

    The only thing else I can suggest is to always run your application in admin mode.

    ~没有更多了~
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文