Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2011-02-15
4
Medium Priority
?
687 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

The main intent of this article is to make you aware of ‘Exchange fail to mount’ error, its effects, causes, and solution.
Here in this article, you will get a step by step guidance on how to restore an Exchange database to a recovery database. Get a brief on Recovery Database and how it can be used to restore Exchange database in this section!
An overview on how to enroll an hourly employee into the employee database and how to give them access into the clock in terminal.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

604 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