Multiple programmers make their effort to implement custom logging subsystems for their applications. In many cases, services of this type require initialisation and de-initialisation, which makes the programmer responsible for stability of the application. In contrast, solution presented below consist of only one VI. It doesn't require any initialisation. It is using OutputDebugString function of Windows Kernel, which posts user's messages to the system log. System log can be monitored by external tools, like DebugView. It is also worth mentioning that DebugView allows the user to debug not only local machine, but also remote ones. VI described in this article is based on String Utils library which makes it greatly scalable and easy to use. Let's have a look on the example (click image to download VI):

Example

Code above can be considered as a typical scenario. First call to Write To Sys Log.vi only prints informational header. Second and third call log input data. Note that there is no need of formating it. Clusters are directly wired to the VI. Finally, last call logs entire error cluster. Result of execution looks like below:

Example

Write To Sys Log.vi can be found in System Utils library. It is free and open source.


Please note that before using it, one must specify SYSLOG_ENABLED=TRUE symbol in his project. Otherwise, Write To Sys Log.vi is discarded in the code and introduces no overhead for the application.

As documentation mentions, error input of the VI is connected directly to error output and has not impact on execution of the VI. VI itself never returns any errors (eventual errors are suppressed).