|
From: Derek A. <wa...@MI...> - 2002-09-18 01:16:37
|
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
|
|
From: Bastiaan B. <Bas...@li...> - 2002-09-18 09:19:21
|
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 |
|
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
|
|
From: Bastiaan B. <Bas...@li...> - 2002-09-18 14:05:14
|
On Wed, 2002-09-18 at 15:45, Derek Atkins wrote: > 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. > The assumption is that in the RemoteSyslogAppnder one specifies the facility using its defined constant, eg. LOG_NEWS, rather than an explicit numeric value. All the constants are already multiplied by 8. This is what openlog(3) expects as well. > A side note: it appears that the PropertyConfigurator is not properly > reading the facility number for a "SyslogAppender" from the > configuration file. Hmm, yes, that's a bug. I'll add the multiplication. Ideally the .facility property should accept names as well as values. Cheers, Bastiaan Bakker LifeLine Networks bv > > -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 |
|
From: Derek A. <wa...@MI...> - 2002-09-18 14:24:33
|
Bastiaan Bakker <Bas...@li...> writes:
> The assumption is that in the RemoteSyslogAppnder one specifies the
> facility using its defined constant, eg. LOG_NEWS, rather than an
> explicit numeric value. All the constants are already multiplied by 8.
> This is what openlog(3) expects as well.
True...
> > A side note: it appears that the PropertyConfigurator is not properly
> > reading the facility number for a "SyslogAppender" from the
> > configuration file.
>
> Hmm, yes, that's a bug. I'll add the multiplication. Ideally the
> .facility property should accept names as well as values.
I was having the problem that the getInt() was returning the default
even if I put a valid number in there.. Although providing a name
would be usefule.
PS_ Thanks for all your work on log4cpp!
> Cheers,
>
> Bastiaan Bakker
> LifeLine Networks bv
-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
|
|
From: Bastiaan B. <Bas...@li...> - 2002-09-18 15:42:29
|
On Wed, 2002-09-18 at 16:24, Derek Atkins wrote: > Bastiaan Bakker <Bas...@li...> writes: > > > The assumption is that in the RemoteSyslogAppnder one specifies the > > facility using its defined constant, eg. LOG_NEWS, rather than an > > explicit numeric value. All the constants are already multiplied by 8. > > This is what openlog(3) expects as well. > > True... > > > > A side note: it appears that the PropertyConfigurator is not properly > > > reading the facility number for a "SyslogAppender" from the > > > configuration file. > > > > Hmm, yes, that's a bug. I'll add the multiplication. Ideally the > > .facility property should accept names as well as values. > > I was having the problem that the getInt() was returning the default > even if I put a valid number in there.. Although providing a name > would be usefule. > Can you find out what's going wrong? The 'name' variant will not be ready for 0.3.2, but a fix for your problem will. > PS_ Thanks for all your work on log4cpp! Thanks. Bastiaan Bakker > > > Cheers, > > > > Bastiaan Bakker > > LifeLine Networks bv > > -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 |
|
From: Derek A. <wa...@MI...> - 2002-09-18 16:41:57
|
Bastiaan Bakker <Bas...@li...> writes:
> Can you find out what's going wrong?
Actually, nothing -- it was me not understanding the interface. When
I set the facility to "16" I got my logs at mail.* (where one would
expect), so it is working, just confusing.
> The 'name' variant will not be ready for 0.3.2, but a fix for your
> problem will.
No worries.
-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
|