This plugin allows you to define custom log files which may be used from HSL (logger(id, data)
). The file may be reopened after a rotate using the halonctl command.
# halonctl plugin command logger reopen mylog1
Follow the instructions in our manual to add our package repository and then run the below command.
apt-get install halon-extras-logger
yum install halon-extras-logger
For the configuration schema, see logger.schema.json.
Important!
If using the
/var/log/halon/
folder as in the sample below and it does not exist, when you create it - give it the same permission as thesmtpd
process is using. Eg.mkdir /var/log/halon chown halon:staff /var/log/halon
plugins:
- id: logger
config:
logs:
- id: mylog
path: /var/log/halon/mylog.log
fsync: false
You can use this plugin with logrotate. A sample configuration could look like this.
/var/log/halon/test.log {
su halon halon
create 640 halon halon
compress
rotate 30
daily
missingok
notifempty
postrotate
/opt/halon/bin/halonctl plugin command logger reopen test
endscript
}
These functions needs to be imported from the extras://logger
module path.
Log data to a log file based on its ID.
Params
- id
string
- The file ID - data
string
- The data
Returns
Returns true
if the data was logged successfully. On error none
is returned.
Example
import { logger } from "extras://logger";
logger("mylog", "hello\n");
This plugin creates files needed and used by the smtpd
process, hence this plugin does not autoload when running the hsh
script interpreter. There are two issues that may occur
- Bad file permission if logs are created by the user running
hsh
not thesmtpd
process - Log files may be corrupted if multiple processes are writing to the same log file simultaneously (
smtpd
andhsh
). Do use this plugin inhsh
ifsmtpd
is running and vice versa.
To overcome the first issue, run hsh
as root
and use the --privdrop
flag to become the same user as smtpd
is using.
hsh --privdrop --plugin logger