problem getting logger and syslogd working together correctly

Christopher Barry christopher.barry at rackwareinc.com
Sun Dec 6 01:36:12 UTC 2009


On Thu, 2009-12-03 at 01:47 +0100, Denys Vlasenko wrote: 
> On Tuesday 01 December 2009 20:59, Christopher Barry wrote:
> > Greetings everyone. I'm having some trouble with logger, and wanted some
> > fresh eyes to have a look at this. The problem is that logger is not
> > writing to the file I have specified locally. ${log_dir} is set to a
> > directory, and it exists.

Thanks Denys for your reply. I do appreciate you taking the time here.

> > 
> > Early on I start syslogd and klogd as below:
> > 
> > klogd -c 6
> > syslogd -l 6 -O /var/log/ramfs/messages
> > 
> > Next, I test to see if VERBOSE is set, if it is, I want logger to output
> > to the console as well as the file.
> 
> There is not need to obfuscate your example with irrelevant details.
> Looks like if VERBOSE != true, you don't use logger. You can drop
> half of the code from the example.
> 

let me clean this up a bit then...

> > 
> > log()
> > {
> >     if [ "${VERBOSE}" == "true" ]
> >     then
> >             logger -p user.info -s -t ramfs "my message"
> >     else
> >             logger -p user.info -t ramfs "my message"
> >     fi
> >     return 0
> > }

Hopefully now you can see what it does more clearly. Obviously logger
will still execute if VERBOSE is not true - it will just not have the -s
switch on it's command line.

> > 
> > 
> > If I set VERBOSE, the logger output goes to the screen. At no time does
> > it go to the local file.
> 
> I run my syslogd this way: "syslogd -m 0 -n -s 99 -b 9 -O logfile".

I do not have those switches in my BB syslogd. Maybe I built it without
some features enabled?

Here is my --help output:
BusyBox v1.15.1 (2009-10-04 14:15:36 EDT) multi-call binary

Usage: syslogd [OPTIONS]

System logging utility.
Note that this version of syslogd ignores /etc/syslog.conf.

Options:
-n Run in foreground
-O FILE Log to given file (default:/var/log/messages)
-l n Set local log level
-S Smaller logging output
-R HOST[:PORT] Log to IP or hostname on PORT (default PORT=514/UDP)
-L Log locally and via network (default is network only if -R)
-D Drop duplicates
-C[size(KiB)] Log to shared mem buffer (read it using logread)

I'm apparently missing -m and -s and -b switches. I do have -O, which I
am using.

> 
> When I do this:
> 
> shadow:~# logger -p user.debug -s -t ramfs "a message"
> ramfs: a message
> shadow:~# logger -p user.warning -s -t ramfs "a message"
> ramfs: a message
> 
> I see this in logfile:
> 
> Dec  3 01:42:23 shadow user.debug ramfs: a message
> Dec  3 01:42:32 shadow user.warn ramfs: a message
> 
> Do you? If not, run strace -oLOG logger -p user.debug -s -t ramfs 'a message'
> and post LOG.

using BB logger against the syslog-ng on my dev box while I'm on my dev
box works fine. logs to a file, and to the screen without issue. I get
the same output as you do.

if I start BB syslogd on my dev box, it exhibits the same behavior as in
the initramfs. BB logger outputs to screen only, and only with -s as
expected. trace log attached.

> 
> > Oddly, the klogd output goes to the file fine 
> > if ${log_level} is high enough (stuff starts showing up at 5).
> > 
> > Later, once the network is active, I kill syslogd and restart it with
> > the following.
> > 
> > # restart syslog with remote logging
> syslogd -l 6 -O /var/log/ramfs/messages -L -R 192.168.1.5

running syslogd in the initramfs this way, logger logs to the remote
logserver, but still not locally.

> > 
> > All of the logging output does go to the remote logging host once this
> > syslogd is started, into a file  ,4msu  named 'user' - both logger and kernel -
> > with VERBOSE set and unset.
> > 
> > My desire and expectation is that all logging goes to the local file at
> > all times. Once the remote logging syslogd comes up, I want logging from
> > that point on to go to the remote, and to continue logging locally. If
> > VERBOSE is set, I expect all of the above, plus screen output.
> 
> Your script won't log to syslog at all if VERBOSE != true.

So, to clarify, logger *is* logging to the remote syslog fine right now.
It does this regardless of the value of VERBOSE.

The script does in fact work correctly without VERBOSE set. It's working
now to log remotely. With that cleared up, hopefully you can help me
deduce what is really happening here - which looks like I may not have
built syslogd right or something.

Thanks again,
-C

> --
> vda
> 

-------------- next part --------------
execve("/home/cbarry/src/bin/logger", ["/home/cbarry/src/bin/logger"..., "-p", "user.info", "-s", "-t", "fred", "this is the message"], [/* 26 vars */]) = 0
uname({sys="Linux", node="rmm01", ...}) = 0
brk(0)                                  = 0x8700000
brk(0x8700cd0)                          = 0x8700cd0
set_thread_area(0xffaa4e9c)             = 0
open("/dev/urandom", O_RDONLY)          = 3
read(3, "\363\301\221s", 4)             = 4
close(3)                                = 0
brk(0x8721cd0)                          = 0x8721cd0
brk(0x8722000)                          = 0x8722000
getpid()                                = 16975
open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/locale.alias", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=2570, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xfffffffff772e000
read(3, "# Locale name alias data base.\n#"..., 1024) = 1024
read(3, " entries are case independent.\n\n"..., 1024) = 1024
read(3, "R\nko_KR\t\tko_KR.eucKR\nlithuanian "..., 1024) = 522
read(3, "", 1024)                       = 0
close(3)                                = 0
munmap(0xf772e000, 4096)                = 0
open("/usr/lib/locale/en_US.UTF-8/LC_IDENTIFICATION", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/locale/en_US.utf8/LC_IDENTIFICATION", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=373, ...}) = 0
mmap2(NULL, 373, PROT_READ, MAP_PRIVATE, 3, 0) = 0xfffffffff772e000
close(3)                                = 0
open("/usr/lib/gconv/gconv-modules.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=26048, ...}) = 0
mmap2(NULL, 26048, PROT_READ, MAP_SHARED, 3, 0) = 0xfffffffff7727000
close(3)                                = 0
open("/usr/lib/locale/en_US.UTF-8/LC_MEASUREMENT", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/locale/en_US.utf8/LC_MEASUREMENT", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=23, ...}) = 0
mmap2(NULL, 23, PROT_READ, MAP_PRIVATE, 3, 0) = 0xfffffffff7726000
close(3)                                = 0
open("/usr/lib/locale/en_US.UTF-8/LC_TELEPHONE", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/locale/en_US.utf8/LC_TELEPHONE", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=59, ...}) = 0
mmap2(NULL, 59, PROT_READ, MAP_PRIVATE, 3, 0) = 0xfffffffff7725000
close(3)                                = 0
open("/usr/lib/locale/en_US.UTF-8/LC_ADDRESS", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/locale/en_US.utf8/LC_ADDRESS", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=155, ...}) = 0
mmap2(NULL, 155, PROT_READ, MAP_PRIVATE, 3, 0) = 0xfffffffff7724000
close(3)                                = 0
open("/usr/lib/locale/en_US.UTF-8/LC_NAME", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/locale/en_US.utf8/LC_NAME", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=77, ...}) = 0
mmap2(NULL, 77, PROT_READ, MAP_PRIVATE, 3, 0) = 0xfffffffff7723000
close(3)                                = 0
open("/usr/lib/locale/en_US.UTF-8/LC_PAPER", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/locale/en_US.utf8/LC_PAPER", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=34, ...}) = 0
mmap2(NULL, 34, PROT_READ, MAP_PRIVATE, 3, 0) = 0xfffffffff7722000
close(3)                                = 0
open("/usr/lib/locale/en_US.UTF-8/LC_MESSAGES", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/locale/en_US.utf8/LC_MESSAGES", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
close(3)                                = 0
open("/usr/lib/locale/en_US.utf8/LC_MESSAGES/SYS_LC_MESSAGES", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=52, ...}) = 0
mmap2(NULL, 52, PROT_READ, MAP_PRIVATE, 3, 0) = 0xfffffffff7721000
close(3)                                = 0
open("/usr/lib/locale/en_US.UTF-8/LC_MONETARY", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/locale/en_US.utf8/LC_MONETARY", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=286, ...}) = 0
mmap2(NULL, 286, PROT_READ, MAP_PRIVATE, 3, 0) = 0xfffffffff7720000
close(3)                                = 0
open("/usr/lib/locale/en_US.UTF-8/LC_COLLATE", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/locale/en_US.utf8/LC_COLLATE", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=966938, ...}) = 0
mmap2(NULL, 966938, PROT_READ, MAP_PRIVATE, 3, 0) = 0xfffffffff7633000
close(3)                                = 0
open("/usr/lib/locale/en_US.UTF-8/LC_TIME", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/locale/en_US.utf8/LC_TIME", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=2454, ...}) = 0
mmap2(NULL, 2454, PROT_READ, MAP_PRIVATE, 3, 0) = 0xfffffffff7632000
close(3)                                = 0
open("/usr/lib/locale/en_US.UTF-8/LC_NUMERIC", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/locale/en_US.utf8/LC_NUMERIC", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=54, ...}) = 0
mmap2(NULL, 54, PROT_READ, MAP_PRIVATE, 3, 0) = 0xfffffffff7631000
close(3)                                = 0
open("/usr/lib/locale/en_US.UTF-8/LC_CTYPE", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/locale/en_US.utf8/LC_CTYPE", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=256316, ...}) = 0
mmap2(NULL, 256316, PROT_READ, MAP_PRIVATE, 3, 0) = 0xfffffffff75f2000
close(3)                                = 0
getuid32()                              = 1000
stat64("/etc/busybox.conf", 0xffaa4e54) = -1 ENOENT (No such file or directory)
getgid32()                              = 1000
setgid32(1000)                          = 0
setuid32(1000)                          = 0
geteuid32()                             = 1000
socket(PF_FILE, 0x80801 /* SOCK_??? */, 0) = 3
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
close(3)                                = 0
socket(PF_FILE, 0x80801 /* SOCK_??? */, 0) = 3
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
close(3)                                = 0
open("/etc/nsswitch.conf", O_RDONLY)    = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=475, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xfffffffff75f1000
read(3, "# /etc/nsswitch.conf\n#\n# Example"..., 1024) = 475
read(3, "", 1024)                       = 0
close(3)                                = 0
munmap(0xf75f1000, 4096)                = 0
open("libnss_compat.so.2", O_RDONLY)    = -1 ENOENT (No such file or directory)
open("/home/cbarry/src/output/lib/libnss_compat.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/cbarry/src/output/lib", {st_mode=S_IFDIR|0755, st_size=824, ...}) = 0
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=20918, ...}) = 0
mmap2(NULL, 20918, PROT_READ, MAP_PRIVATE, 3, 0) = 0xfffffffff75ec000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/libnss_compat.so.2", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20\23\0\0\0\0\0\0"..., 512) = 512
close(3)                                = 0
stat64("/lib", {st_mode=S_IFDIR|0755, st_size=7168, ...}) = 0
open("/usr/lib/libnss_compat.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/usr/lib", {st_mode=S_IFDIR|0755, st_size=20480, ...}) = 0
open("/lib/i486-linux-gnu/libnss_compat.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/i486-linux-gnu", 0xffaa47a0) = -1 ENOENT (No such file or directory)
open("/usr/lib/i486-linux-gnu/libnss_compat.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/i486-linux-gnu", 0xffaa47a0) = -1 ENOENT (No such file or directory)
munmap(0xf75ec000, 20918)               = 0
time(NULL)                              = 1259807851
open("/etc/localtime", O_RDONLY)        = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=3519, ...}) = 0
fstat64(3, {st_mode=S_IFREG|0644, st_size=3519, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xfffffffff75f1000
read(3, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\0\0\0\4\0\0\0\0"..., 1024) = 1024
read(3, "\0\1\0\1\0\1\0\1\2\3\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0"..., 1024) = 1024
_llseek(3, 1447, [3495], SEEK_CUR)      = 0
read(3, "\nEST5EDT,M3.2.0,M11.1.0\n", 1024) = 24
close(3)                                = 0
munmap(0xf75f1000, 4096)                = 0
writev(2, [{"fred: this is the message", 25}, {"\n", 1}], 2) = 26
socket(PF_FILE, 0x80002 /* SOCK_??? */, 0) = 3
connect(3, {sa_family=AF_FILE, path="/dev/log"}, 110) = 0
send(3, "<14>Dec  2 21:37:31 fred: this i"..., 45, MSG_NOSIGNAL) = 45
close(3)                                = 0
exit_group(0)                           = ?


More information about the busybox mailing list