|
From: Derek A. <wa...@MI...> - 2002-09-18 13:45:25
|
Thanks. I realized (after I went to bed) that this patch assumes you
supply a valid facility number for remote logging (i.e. you supply
facility * 8). A (slightly) better "patch" would be:
int facility = ((_facility & 7) ? (_facility<<3) : _facility);
int priority = facility + toSyslogPriority(event.priority);
This way if you supply a facility of '1' (for log_user) it will still
do the right thing (by converting it to '8'). Unfortunately this will
fail for people who supply an '8' for log_uucp or '16' for log_local0,
but it should work for all other log facilities.
A side note: it appears that the PropertyConfigurator is not properly
reading the facility number for a "SyslogAppender" from the
configuration file.
-derek
Bastiaan Bakker <Bas...@li...> writes:
> Hi Derek,
>
> Thanks for the report. This bug appears to be present in all log4cpp
> versions. Merged your patch, 0.3.2 final should be OK.
>
> Cheers,
>
> Bastiaan
>
>
> On Wed, 2002-09-18 at 03:16, Derek Atkins wrote:
> > The RemoteSyslogAppender in both 0.3.2rc4 and rc5 fail to log
> > to the proper facility. In fact, it will always log to LOG_KERN
> > (which is not what I want).
> >
> > This patch fixes the code to log properly (given a valid facility):
> >
> > --- src/RemoteSyslogAppender.cpp~ Tue Jul 2 18:14:37 2002
> > +++ src/RemoteSyslogAppender.cpp Tue Sep 17 20:41:39 2002
> > @@ -125,7 +125,7 @@
> > std::string message(_getLayout().format(event));
> > int len = message.length() + 16;
> > char *buf = new char [len];
> > - int priority = toSyslogPriority(event.priority);
> > + int priority = _facility + toSyslogPriority(event.priority);
> > int len2 = sprintf (buf, "<%d>", priority);
> > memcpy (buf + len2, message.data(), len - 16);
> > sockaddr_in sain;
> >
> > Thanks,
> >
> > -derek
> > --
> > Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
> > Member, MIT Student Information Processing Board (SIPB)
> > URL: http://web.mit.edu/warlord/ PP-ASEL-IA N1NWH
> > wa...@MI... PGP key available
>
>
--
Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
Member, MIT Student Information Processing Board (SIPB)
URL: http://web.mit.edu/warlord/ PP-ASEL-IA N1NWH
wa...@MI... PGP key available
|