开发者

newbie question on win32 app log

I am new in in Visual Studio Win32 (C++) Ap开发者_C百科plications

In java where I work, logging is easy using log4j for instance.

How is the logging done in a Win32 app?

I have seen some code using macros to write to files.

Am I responsible to create some logging mechanism?

Is there a standard way to log in win32?

Thanks


Use the Event Log API to write to Windows Event Log http://msdn.microsoft.com/en-us/library/aa385772(v=vs.85).aspx


Another way is using log4net since you have experience of log4j, there are very similar.


"Windows application" doesn't mean much of anything, Java apps can also run on Windows. There's log4net to adding logging to a .NET application. Log4cxx to do so for an app written in C++. Exact same approach as log4j. The project's home page is here.


It depends on who is going to be using your software's logging facility:

  • The Windows Event Log API is best if you are writing a service or "system" type task that needs to be supported by an IT support department. Support tools for Windows support remote access of system event logs to create system health alerts and so on.

Other than that, Windows does not have a convenient Logging API. So you need to roll-your own if the system event log is inappropriate.

  • For developers / debugging purposes theres OutputDebugString that will emit text to your debuggers "Output" window.

  • It is convenient when writing GUI apps, to make the debug build a console application, so that a console window is displayed in addition to the GUI. printf() can display messages to the console.

  • Otherwise, some OSS projects I built on windows did include a variant of log4c that had been ported to windows. So log4c can be coerced into working on windows if you really need it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜