Solved

cygwin1.dll - Redirect syslog() calls to file instead of Windows Event Log

Posted on 2011-02-15
4
667 Views
Last Modified: 2013-11-15
Hi there,

I have an app that is built against cygwin, producing an x86 WIN32 executable. This is a console app. However, its default behaviour (presumably because it uses functions in cygwin1.dll) is to send any calls to syslog() under a Windows environment to the Windows Event Log (can be seen in Event Viewer).

Is there a simple way, without changing the source code, say by placing a config file somewhere, that changes this behaviour such that any log information is redirected to a file not the Windows Event log? Or alternatively, sends nothing at all (some /dev/null equivalent)?

Hoping I can avoid removing all such calls and recompiling...

Kind regards,

Xav.
0
Comment
Question by:xavier_da
  • 3
4 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 34901009
Hi,

I'm not very familiar with Cygwin, but it seems that you need a running syslogd to capture the messages to a logfile.

As far as I know there is a syslogd in inetutils
http://sourceware.org/cygwin/packages/inetutils/ (package list)


and a syslog-ng implementation is also available:
http://sourceware.org/cygwin/packages/syslog-ng/ (package list)

Both packages should contain READMEs to give you a start.

wmp



0
 

Author Comment

by:xavier_da
ID: 34903135
Hi woolmilkporc,

Thanks for your response. However, this is a standalone executable built using Cygwin - I have no actual Cygwin environment installed.

My understanding is that the cygwin1.dll provides a layer to abstract services and features typical of a Unix environment, such that calls to normal functions (such as syslog()) are portable, and can run under Windows. In this case, code that under a Unix environment would cause a message to be sent to the syslog daemon is passed onto the Windows equivalent (Event Viewer).

Is there a cygwin1.dll file with different logging functionality? I'd be happy to remove any logging, yet keep the calls in there, so it essentially calls a stub function of some kind.

I assume the Windows implementation of the syslog() function call does some checks to see how to send messages. Maybe it checks for the presence of a file in the same directory as the calling application (with cygwin1.dll), a text file that alters the logging behaviour?

Or failing that, is the only way to do what I want to:
a) alter the cygwin1.dll to exclude syslog()
b) add conditional code and a command line option to NOT send any messages.
c) ???

What other alternatives are there?

Regards,

Xav.
0
 

Accepted Solution

by:
xavier_da earned 0 total points
ID: 34977158
Okay,

As mentioned, any call to syslog() in a Cygwin app gets shunted to the Windows event log in the absence of a syslog daemon. To suppress these messages, I made a simple alteration to the source code, using setlogmask():

setlogmask ( ~(LOG_MASK(LOG_INFO) | LOG_MASK(LOG_ERR)) );
openlog("app", LOG_CONS, LOG_DAEMON);

Open in new window


In this case, the LOG_MASK macro is used with the complement operator to suppress INFO and ERR event messages.

Downside is that I cannot see any messages dumped to the console, but I wanted silent operation anyway.

Just made the above change and recompiled using Cygwin. No more messages appear!

Kind regards,

Xav.
0
 

Author Closing Comment

by:xavier_da
ID: 35005382
Solution found independently of wider EE community; meets original goal.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Free HD cloner 11 63
cloning computer 13 86
Installation of Nessus Professional 5 99
Pay to 支付宝 12 32
In this article, you will read about the trends across the human resources departments for the upcoming year. Some of them include improving employee experience, adopting new technologies, using HR software to its full extent, and integrating artifi…
This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
Using Adobe Premiere Pro, the viewer will learn how to set up a sequence with proper settings, importing pictures, rendering, and exporting the finished product.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question