2

I am using Elementary OS Freya 0.3.2 64 bit and since the beginning I have some issues with logs - my installed applications (dovecot, postfix, clamav and others) can't log properly simply because /var/log directory is recreated every time after I reboot the OS and it seems no new directories and files can be automatically created, so I get something like:

/etc/cron.daily/logrotate:
error: stat of /var/log/clamav/clamav.log failed: No such file or directory
run-parts: /etc/cron.daily/logrotate exited with return code 1
/etc/cron.daily/trim:
/: 15232020480 bytes were trimmed

and

ERROR: Problem with internal logger (UpdateLogFile = /var/log/clamav/freshclam.log).
ERROR: Can't open /var/log/clamav/freshclam.log in append mode (check permissions!).

When I manually create those log files everything works until next reboot when I see they are all gone. I tried to mess up with rsyslog and logrotate configs but nothing worked.

This is how /var/log looks like after reboot (notice the lack of dovecot, clamav, mail etc.):

ls -la /var/log
total 316
drwxr-xr-x  7 root root    260 lut 20 08:46 .
drwxr-xr-x 14 root root   4096 sty 16 15:11 ..
drwxrwxrwt  2 root root     40 lut 20 08:46 apt
-rw-r--r--  1 root root   5387 lut 20 08:46 boot.log
drwxr-xr-x  2 root root     60 lut 20 08:46 ConsoleKit
drwxr-x---  2 root lp      100 lut 20 08:46 cups
-rw-r--r--  1 root adm   62367 lut 20 08:46 dmesg
-rw-r--r--  1 root root      0 lut 20 08:46 dmesg.0
-rw-r--r--  1 root root   1542 lut 20 08:46 gpu-manager.log
drwx--x--x  2 root root     80 lut 20 08:46 lightdm
drwxr-xr-x  3 root root    180 lut 20 08:46 samba
-rw-r--r--  1 root root 192373 lut 20 08:46 udev
-rw-r--r--  1 root root  47347 lut 20 08:47 Xorg.0.log

As I'm new to Linux I don't exactly know which configs come into play when dealing with logs but I guess those are the common. You can see some of my modifications for mail server for example. So I'm out of ideas what should I tweak now and asking for your help.

cat /etc/rsyslog.conf

cat /etc/rsyslog.conf
#  /etc/rsyslog.conf    Configuration file for rsyslog.
#
#           For more information see
#           /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html
#
#  Default logging rules can be found in /etc/rsyslog.d/50-default.conf


#################
#### MODULES ####
#################

$ModLoad imuxsock # provides support for local system logging
$ModLoad imklog   # provides kernel logging support
#$ModLoad immark  # provides --MARK-- message capability

# provides UDP syslog reception
#$ModLoad imudp
#$UDPServerRun 514

# provides TCP syslog reception
#$ModLoad imtcp
#$InputTCPServerRun 514

# Enable non-kernel facility klog messages
$KLogPermitNonKernelFacility on

###########################
#### GLOBAL DIRECTIVES ####
###########################

#
# Use traditional timestamp format.
# To enable high precision timestamps, comment out the following line.
#
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat

# Filter duplicated messages
$RepeatedMsgReduction on

#
# Set the default permissions for all log files.
#

$FileOwner syslog
$FileGroup adm
$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022
$PrivDropToUser syslog
$PrivDropToGroup syslog

#
# Where to place spool and state files
#
$WorkDirectory /var/spool/rsyslog

#
# Include all config files in /etc/rsyslog.d/
#
$IncludeConfig /etc/rsyslog.d/*.conf

ls /etc/rsyslog.d

ls /etc/rsyslog.d
20-ufw.conf  50-default.conf  50-default.conf~  postfix.conf

cat /etc/rsyslog.d/50-default.conf

cat /etc/rsyslog.d/50-default.conf
#  Default rules for rsyslog.
#
#           For more information see rsyslog.conf(5) and /etc/rsyslog.conf

#
# First some standard log files.  Log by facility.
#
auth,authpriv.*         /var/log/auth.log
*.*;mail.none;mail.error;auth,authpriv.none     -/var/log/syslog
#cron.*             /var/log/cron.log
#daemon.*           -/var/log/daemon.log
kern.*              -/var/log/kern.log
#lpr.*              -/var/log/lpr.log
mail.*              -/var/log/mail.log
#user.*             -/var/log/user.log

#
# Logging for the mail system.  Split it up so that
# it is easy to write scripts to parse these files.
#
mail.info           -/var/log/mail.info
mail.warn           -/var/log/mail.warn
mail.err            /var/log/mail.err

#
# Logging for INN news system.
#
news.crit           /var/log/news/news.crit
news.err            /var/log/news/news.err
news.notice         -/var/log/news/news.notice

#
# Some "catch-all" log files.
#
#*.=debug;\
#   auth,authpriv.none;\
#   news.none;mail.none -/var/log/debug
#*.=info;*.=notice;*.=warn;\
#   auth,authpriv.none;\
#   cron,daemon.none;\
#   mail,news.none      -/var/log/messages

#
# Emergencies are sent to everybody logged in.
#
*.emerg                                :omusrmsg:*

#
# I like to have messages displayed on the console, but only on a virtual
# console I usually leave idle.
#
#daemon,mail.*;\
#   news.=crit;news.=err;news.=notice;\
#   *.=debug;*.=info;\
#   *.=notice;*.=warn   /dev/tty8

# The named pipe /dev/xconsole is for the `xconsole' utility.  To use it,
# you must invoke `xconsole' with the `-file' option:
# 
#    $ xconsole -file /dev/xconsole [...]
#
# NOTE: adjust the list below, or you'll go crazy if you have a reasonably
#      busy site..
#
#daemon.*;mail.*;\
#   news.err;\
#   *.=debug;*.=info;\
#   *.=notice;*.=warn   |/dev/xconsole

cat /etc/rsyslog.d/postfix.conf

cat /etc/rsyslog.d/postfix.conf 
# Create an additional socket in postfix's chroot in order not to break
# mail logging when rsyslog is restarted.  If the directory is missing,
# rsyslog will silently skip creating the socket.
$AddUnixListenSocket /var/spool/postfix/dev/log 

cat /etc/logrotate.conf

cat /etc/logrotate.conf
# see "man logrotate" for details
# rotate log files weekly
weekly

# use the syslog group by default, since this is the owning group
# of /var/log/syslog.
su root syslog

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# uncomment this if you want your log files compressed
#compress

# packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp, or btmp -- we'll rotate them here
/var/log/wtmp {
    missingok
    monthly
    create 0664 root utmp
    rotate 1
}

/var/log/btmp {
    missingok
    monthly
    create 0660 root utmp
    rotate 1
}

# system-specific logs may be configured here

ls /etc/logrotate.d

ls /etc/logrotate.d
apache2   clamav-daemon     fail2ban         owncloud       samba                winbind
apport    clamav-freshclam  irony            ppp            speech-dispatcher
apt       consolekit        kolab-freebusy   roundcubemail  ufw
aptitude  cups-daemon       kolab-syncroton  rsyslog        unattended-upgrades
chwala    dpkg              mysql-server     rsyslog~       upstart

cat /etc/logrotate.d/rsyslog

cat /etc/logrotate.d/rsyslog
/var/log/syslog
{
    rotate 7
    daily
    missingok
    notifempty
    delaycompress
    compress
    postrotate
        reload rsyslog >/dev/null 2>&1 || true
    endscript
}

/var/log/dovecot.log {
    rotate 7
    daily
        create 0660 vmail vmail
    missingok
    notifempty
    delaycompress
    compress
}

/var/log/mail.info
/var/log/mail.warn
/var/log/mail.err
/var/log/mail.log
/var/log/daemon.log
/var/log/kern.log
/var/log/auth.log
/var/log/user.log
/var/log/lpr.log
/var/log/cron.log
/var/log/debug
/var/log/messages
{
    rotate 4
    weekly
    missingok
    notifempty
    compress
    delaycompress
    sharedscripts
    postrotate
        reload rsyslog >/dev/null 2>&1 || true
    endscript
}
  • Is your /var or /var/log directory mounted as another partition or ramdisk (cf. /etc/fstab)? – lemonslice Nov 13 '16 at 20:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.