尝试写出syslog
包含字符串的条目,但它们没有注册。
// person.name is an NSSTring
syslog(LOG_NOTICE, "Some string %@", person.name);
Run Code Online (Sandbox Code Playgroud) 我在linux上工作,进程rsyslogd正在侦听端口514.以下代码无法写入/ var/log/syslog.有谁知道这是什么问题?
import logging
import logging.handlers
root_logger = logging.getLogger()
root_logger.setLevel(config.get_value("log_level"))
syslog_hdlr = SysLogHandler(address='/dev/log', facility=SysLogHandler.LOG_DAEMON)
syslog_hdlr.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(name)s: %(levelname)s %(message)s')
syslog_hdlr.setFormatter(formatter)
root_logger.addHandler(syslog_hdlr)
logger = logging.getLogger("imapcd.daemon")
logger.debug('test')
Run Code Online (Sandbox Code Playgroud) 我是中国人.我正在阅读syslog.h,我找到一个我无法理解的术语"0大数字".我可以理解孔段的含义,但我仍然对"0"一词感到好奇 - 大号",任何人都可以解释这个词吗?
/*
* priorities/facilities are encoded into a single 32-bit quantity, where the
* bottom 3 bits are the priority (0-7) and the top 28 bits are the facility
* (0-big number). Both the priorities and the facilities map roughly
* one-to-one to strings in the syslogd(8) source code. This mapping is
* included in this file.
/* facility codes */
#define LOG_KERN (0<<3) /* kernel messages */
#define LOG_USER (1<<3) /* random user-level messages */
....
*/
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用netty通过SSL写入syslog服务器,我想我已经开始关注netty部分了,我似乎只需要添加以下行: channel.pipeline().addLast("ssl", sslCtx.newHandler(channel.alloc(), host, 5000))
。
完整代码:
bootstrap.channel(NioSocketChannel.class)
.option(ChannelOption.SO_KEEPALIVE, true)
.handler(new TcpSyslogEventEncoder());
try {
ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, 5000));
channel = future.syncUninterruptibly().channel();
channel.pipeline().addLast("ssl", sslCtx.newHandler(channel.alloc(), host, 5000));
}
catch (Exception e) {
System.out.println("Unable to connect to host. Cause is " + e.toString());
}
Run Code Online (Sandbox Code Playgroud)
我的问题是获取SslContext(sslCtx)对象设置。我已经有了要使用的证书(这是一个.crt文件,其中包含以下文本:
-----BEGIN CERTIFICATE-----
MIIDBjCCAe4CCQCmD....gM8vZVmYXULV8A==
-----END CERTIFICATE-----
Run Code Online (Sandbox Code Playgroud)
我看到必须跳过Java中的铁环负载才能做到这一点。肯定有一种更简单的方法可以将netty与SSL一起使用吗?我设置sslCtx的代码是:
EventLoopGroup group = null;
Bootstrap bootstrap = null;
Channel channel = null;
boolean initialized = false;
boolean connected = false;
java.io.FileInputStream fis = null;
// find out if keystore already …
Run Code Online (Sandbox Code Playgroud) 我想将rsyslogd
可执行文件(守护进程)的所有内容记录到文件中。
# /etc/rsyslog.conf
if $syslogtag isequal 'rsyslogd' then /tmp/foo.log
if $syslogtag isequal 'rsyslogd:' then /tmp/foo.log
if $syslogtag isequal ' rsyslogd' then /tmp/foo.log
if $syslogtag isequal ' rsyslogd:' then /tmp/foo.log
Run Code Online (Sandbox Code Playgroud)
在单独的外壳中:
sv down /root/service/rsyslog/
sv up /root/service/rsyslog/
tail -F /tmp/foo.log
Run Code Online (Sandbox Code Playgroud)
结果:布库斯
所以我编辑rsyslog.conf
:
# /etc/rsyslog.conf
if $syslogtag contains 'rsyslogd' then /tmp/foo.log
Run Code Online (Sandbox Code Playgroud)
冲洗并重复;在一个单独的外壳中:
sv down /root/service/rsyslog/
sv up /root/service/rsyslog/
tail -F /tmp/foo.log
Run Code Online (Sandbox Code Playgroud)
多田:20190424_195027 linuxbox info rsyslogd: [origin software="rsyslogd" swVersion="8.28.0" x-pid="27384" x-info="http://www.rsyslog.com"] start
是什么赋予了?我不明白为什么尝试使用isequals
失败。
看起来%syslogtag%
像是 …