Re: ASL_LEVEL_DEBUG
Re: ASL_LEVEL_DEBUG
- Subject: Re: ASL_LEVEL_DEBUG
- From: Marc Majka <email@hidden>
- Date: Mon, 10 Mar 2008 09:48:15 -0700
This is correct as far as it goes, but there is another filter involved.
When a process calls asl_log (or syslog), there's a filter that
determines whether the message gets sent to syslogd. That's the
filter that you are correctly changing with asl_set_filter. Normally,
the filter screens out Info and Debug level messages, If you set it
to ASL_FILTER_MASK_UPTO(ASL_LEVEL_DEBUG) or LOG_UPTO(LOG_DEBUG) when
using the syslog(3) API, then your process doesn't screen out anything.
When a message is received and processed by syslogd, more sorting and
filtering takes place. For messages that are saved in the ASL
database, there's a filter that's very similar to the client-side
filter. By default, it screens out Info and Debug level messages.
Messages that get saved to the "Legacy" BSD log files, like /var/log/
system.log, have their own filtering rules that are found in /etc/
syslog.conf.
The "syslog" command line utility does a database seacrh, so if you
want to use it to retrieve Debug level messages, you'll need to adjust
the database filter. You can do that temporarily (until the next time
syslogd restarts) with:
sudo syslog -c syslogd -d
That sets syslogd's filter to ASL_FILTER_MASK_UPTO(ASL_LEVEL_DEBUG).
See the syslog(1) man page for details. You can also set the filter
in syslogd's startup plist: /System/Library/LaunchDaemons/
com.apple.syslogd.plist. Add
<string>-c</string>
<string>7</string>
to the ProgramArguments. See the syslogd(8) man page for details. If
you change the plist, you'll need to reboot (or stop and re-start
syslogd using launchctl) for the change to take effect.
--
Marc Majka
On 9 Mar, 2008, at 19:43, John Devlin wrote:
I'd like to send debug messages to the asl system log on Leopard
without using sudo, but haven't had any success.
I compiled and ran a test program (see below).
On 2 Oct 2006, at 10:23 AM, Marc Majka wrote:
Here's a small test program that will also send a "test" message
with the "raduis" facility:
#include <asl.h>
#include <string.h>
int main()
{
aslmsg m = asl_new(ASL_TYPE_MSG);
asl_set_filter(NULL, ASL_FILTER_MASK_UPTO(ASL_LEVEL_DEBUG));
asl_set(m, "Facility", "radius");
asl_log(NULL, m, ASL_LEVEL_DEBUG, "test");
return(0);
}
After which I tried to read the message back from the log
% syslog -k Facility radius
% syslog -k Level 7
but didn't find anything. I checked to make sure the the master
filter was off, and it was.
% syslog -c 0
Master filter mask: Off
So I compiled and ran a second test program (see below).
If you read through the man page, you'd also find that the
following code *should* work:
aslclient a = asl_open(NULL, "radius", 0);
asl_set_filter(NULL, ASL_FILTER_MASK_UPTO(ASL_LEVEL_DEBUG));
asl_log(a, NULL, ASL_LEVEL_DEBUG, "test");
asl_close(a);
return(0);
But due to a bug in asl_open(), it doesn't. Sorry about that! The
bug will be fixed in 10.5 (Leopard).
That didn't work either. I searched the lists for 'ASL_LEVEL_DEBUG'
but didn't come up with anything beyond the two tests above. Any
ideas why neither of those two programs work on 10.5.2? Any ideas
what would?
John
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden