Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm a developer and looking at implementing some logging in my application. I'm considering using the syslog interface for a number of reasons. But, what I can't figure out is whether I can configure my particular application to have it's own log file.

It appears to me that you can't really do it. It's more centralized logging. So servers like apache write their own loggers.

Is this the case? what are the alternatives?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

An application doesn't get to decide what happens to its log messages if syslog is used. That decision is made by the configuration of the syslog daemon.

There are several ways you can control log destinations on a system with syslog:

Your application can be set to log on a particular facility. There are some system-level facilities such as kernel and daemon, as well as eight facilities reserved for local use: local0 through local7. You can either hard-code one of these in to your application or make it selectable through a configuration option.

Even the most basic syslog daemons can be configured to log different facilities to different files.

Another option is that more modern syslog daemons such as syslog-ng and rsyslog can also be configured to scan the message and log to a different destination based on a tag in the message. It's common for many applications to put a tag such as [foo] at the start of their syslog message.

Note that filtering based on a message tag will generally have worse performance, eg: lower log throughput than just filtering on the facility. For high volume syslog servers this can become a bottleneck.

share|improve this answer

I use syslog-ng and I believe it can be used to create separate parallel log files for programs, though I think this may not be ideal because it requires modifying the syslog-ng configuration files per program. Check with your local man pages. :)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.