Syslog_R for Linux

Where does linux store my syslog?

On my Ubuntu machine, I can see the output at /var/log/syslog.

On a RHEL/CentOS machine, the output is found in /var/log/messages.

This is controlled by the rsyslog service, so if this is disabled for some reason you may need to start it with systemctl start rsyslog.

As noted by others, your syslog() output would be logged by the /var/log/syslog file.

You can see system, user, and other logs at /var/log.

For more details: here's an interesting link.

How to check syslog in Bash on Linux?

How about less /var/log/syslog?

How to view syslog in ubuntu?

Looks like you are trying to read syslog from Java, not from an interactive terminal. The text looks like a correct output, but with smashed formatting.

tail -f is good for interactive terminals.

Try cat /var/log/syslog, or just open /var/log/syslog as a file (if your process has enough permissions).

Location of Linux OS syslogs

The choice of whether logs go to /var/log/syslog or /var/log/messages is dependant on distribution type.

RPM based systems such as CentOS and RedHat use /var/log/messages and Debian based systems such as Ubuntu use /var/log/syslog.

How to setup syslog in yocto?

By checking the sources of syslog and busybox I found a possible solution. This solution shows how to configure syslog to log in two logs with max 10MByte:

1.) get valid syslog build config

1.1) download busybox -> git/busybox

1.2) build busybox via bitbake -> bitbake busybox

1.3) copy defconfig file to downloaded busybox -> cp /defconfig git/busybox/

1.4) make menueconfig

1.5) goto "System Logging Utilities"

1.6) deselect klogd because it can colide with printk

1.7) save to "defconfig"

#
# System Logging Utilities
#
# CONFIG_KLOGD is not set
# CONFIG_FEATURE_KLOGD_KLOGCTL is not set
CONFIG_LOGGER=y
CONFIG_LOGREAD=y
CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING=y
CONFIG_SYSLOGD=y
CONFIG_FEATURE_ROTATE_LOGFILE=y
CONFIG_FEATURE_REMOTE_LOG=y
CONFIG_FEATURE_SYSLOGD_DUP=y
CONFIG_FEATURE_SYSLOGD_CFG=y
CONFIG_FEATURE_SYSLOGD_READ_BUFFER_SIZE=256
CONFIG_FEATURE_IPC_SYSLOG=y
CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=64
CONFIG_FEATURE_KMSG_SYSLOG=y

2.) setup your log config

Create "syslog.conf" and enter the rules:
This is an example:

#
# /etc/syslog.conf Configuration file for busybox's syslogd utility
#

kern.notice /var/log/messages


#
# my software messages
#
user.err /var/log/mySWError
user.* /var/log/mySWFull
local0.* /var/log/mySWFull
local0.err /var/log/mySWError
#
#this prevents from logging to default log file (-O FILE or /var/log/messages)
#
*.* /dev/null

3.) modify configuration for the busybox syslog deamon

This example logs to files which are limited to 10 MBytes. If "ROTATESIZE" is not set syslog set the log filesize automatic to 200 kBytes. The content of "syslog-startup.conf" looks like:

# This configuration file is used by the busybox syslog init script,
# /etc/init.d/syslog[.busybox] to set syslog configuration at start time.

DESTINATION=file # log destinations (buffer file remote)
#LOGFILE=/var/log/messages # where to log (file)
REMOTE=loghost:514 # where to log (syslog remote)
REDUCE=no # reduce-size logging
DROPDUPLICATES=no # whether to drop duplicate log entries
ROTATESIZE=10000 # rotate log if grown beyond X [kByte]
#ROTATEGENS=3 # keep X generations of rotated logs
BUFFERSIZE=64 # size of circular buffer [kByte]
FOREGROUND=no # run in foreground (don't use!)
#LOGLEVEL=5 # local log level (between 1 and 8)

4.) get the configuration into yocto build

4.1) create following directory structure in your own layer(meta-custom):

meta-custom/recipes-core/
meta-custom/recipes-core/busybox/
meta-custom/recipes-core/busybox/busybox

4.2) copy into "meta-custom/recipes-core/busybox/busybox":

defconfig
syslog.conf
syslog-startup.conf

4.3) create in "meta-custom/recipes-core/busybox/" "busybox_1.24.1.bbappend". If you using an older/newer version of busybox you need to change the "1.24.1" number to yours. You can find your version in "/poky/meta/recipes-core/busybox/"

Add this two lines to this file:

FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}/poky-tiny:"

5.) build your custom defined syslog

bitbake busybox

and transfer it into the rootfs of the image

bitbake core-image-minimal

Now it should work!

Ubuntu: large syslog and kern.log files

Have you checked the content of those files? There's obviously something going on with your server causing events to be generated. Resolve whatever issue is causing that, and your logs should return to their normal size.

To temporary solve the issue, type

echo "" > /var/log/kern.log
echo "" > /var/log/syslog
service syslog restart
journalctl --vacuum-size=50M

You need to be root user for this: enter sudo su, your password, and then the above commands



Related Topics



Leave a reply



Submit