Linux 在 Windows 上找不到 syslog.h

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9496129/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 04:54:26  来源:igfitidea点击:

cannot find syslog.h on windows

clinuxevent-logsyslog

提问by diligent

I am rewriting a c program which was used to linux, now I'll reused it on windows, I write a bat file. I run this file as administrator, then error occurs: syslog.h:No such file or directory.

我正在重写用于linux的ac程序,现在我将在windows上重用它,我写了一个bat文件。我以管理员身份运行这个文件,然后出现错误:syslog.h:No such file or directory。

Could you please give me some advices? thx.

你能给我一些建议吗?谢谢。

采纳答案by b0ti

Probably the program you are porting to windows uses the syslog(3) function call (in addition to openlog and closelog). These are defined in syslog.h on unix. Windows does not have these, so you can do the following:

可能您移植到 Windows 的程序使用了 syslog(3) 函数调用(除了 openlog 和 closelog)。这些在 unix 上的 syslog.h 中定义。Windows 没有这些,因此您可以执行以下操作:

  • Remove syslog.h and these function calls from the code.
  • Create a syslog.h and implement these calls or just define them as empty macros.
  • Use cygwin which provides POSIX compatibility.
  • 从代码中删除 syslog.h 和这些函数调用。
  • 创建一个 syslog.h 并实现这些调用,或者只是将它们定义为空宏。
  • 使用提供 POSIX 兼容性的 cygwin。

回答by Greg Hewgill

Windows doesn't offer a built-in syslog client. You may be able to use a third-party library, such as http://syslog-win32.sourceforge.net.

Windows 不提供内置的系统日志客户端。您可以使用第三方库,例如http://syslog-win32.sourceforge.net

回答by A T

In PHP source codeyou can find a wrapper based on Windows function ReportEvent().

PHP 源代码中,您可以找到一个基于 Windows 函数的包装器ReportEvent()

E.g.: take a look at wsyslog.cand syslog.h

例如:看看wsyslog.csyslog.h

Edit: have you tried syslog-server?

编辑:你试过syslog-server吗?