本文整理汇总了Java中com.cloudbees.syslog.SyslogMessage类的典型用法代码示例。如果您正苦于以下问题:Java SyslogMessage类的具体用法?Java SyslogMessage怎么用?Java SyslogMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SyslogMessage类属于com.cloudbees.syslog包,在下文中一共展示了SyslogMessage类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: publish
import com.cloudbees.syslog.SyslogMessage; //导入依赖的package包/类
@Override
public void publish(LogRecord record) {
if (!isLoggable(record))
return;
String msg = getFormatter().format(record);
Severity severity = LevelHelper.toSeverity(record.getLevel());
if (severity == null)
severity = this.severity;
SyslogMessage message = new SyslogMessage()
.withTimestamp(record.getMillis())
.withSeverity(severity)
.withAppName(this.appName)
.withHostname(this.messageHostname)
.withFacility(this.facility)
.withMsg(msg);
try {
syslogMessageSender.sendMessage(message);
} catch (IOException e) {
e.printStackTrace();
}
}
示例2: send2
import com.cloudbees.syslog.SyslogMessage; //导入依赖的package包/类
@Ignore
@Test
public void send2() throws Exception {
SyslogMessage msg = new SyslogMessage()
.withAppName("my-app")
.withFacility(Facility.USER)
.withHostname("my-hostname")
.withMsg("my message over tcp éèà " + new Timestamp(System.currentTimeMillis()))
.withSeverity(Severity.INFORMATIONAL)
.withTimestamp(System.currentTimeMillis());
TcpSyslogMessageSender messageSender = new TcpSyslogMessageSender();
messageSender.setSyslogServerHostname("logs2.papertrailapp.com");
messageSender.setSyslogServerPort(46022);
messageSender.setMessageFormat(MessageFormat.RFC_3164);
messageSender.setSsl(true);
System.out.println(msg.toSyslogMessage(messageSender.getMessageFormat()));
messageSender.sendMessage(msg);
}
示例3: sendOverSSL
import com.cloudbees.syslog.SyslogMessage; //导入依赖的package包/类
@Ignore
@Test
public void sendOverSSL() throws Exception {
SyslogMessage msg = new SyslogMessage()
.withAppName("my-app")
.withFacility(Facility.USER)
.withHostname("my-hostname")
.withMsg("my message over tcp ssl éèà " + new Timestamp(System.currentTimeMillis()))
.withSeverity(Severity.INFORMATIONAL)
.withTimestamp(System.currentTimeMillis());
TcpSyslogMessageSender messageSender = new TcpSyslogMessageSender();
messageSender.setSyslogServerHostname("logs2.papertrailapp.com");
messageSender.setSyslogServerPort(46022);
messageSender.setMessageFormat(MessageFormat.RFC_3164);
messageSender.setSsl(true);
System.out.println(msg.toSyslogMessage(messageSender.getMessageFormat()));
messageSender.sendMessage(msg);
}
示例4: append
import com.cloudbees.syslog.SyslogMessage; //导入依赖的package包/类
@Override
protected void append(E loggingEvent) {
try {
SyslogMessage syslogMessage =
syslogConfig.getProtocol().getSyslogMessage(syslogConfig).withSeverity(Severity.fromNumericalCode(getSeverityForEvent(loggingEvent)))
.withMsg(layout.doLayout(loggingEvent)).withFacility(Facility.USER).withAppName(syslogConfig.getProgramName())
.withHostname(InetAddress.getLocalHost().getHostName());
syslogMessageSender.sendMessage(syslogMessage);
} catch (IOException e) {
e.printStackTrace();
}
}
示例5: logEvent0
import com.cloudbees.syslog.SyslogMessage; //导入依赖的package包/类
@Override
protected void logEvent0(PciAuditEvent event) {
if (!initialized) {
LOG.error("syslog audit not initialiazed");
return;
}
CharArrayWriter msg = event.toCharArrayWriter(prefix);
final int n = msg.size();
if (n > maxMessageLength) {
LOG.warn("syslog message exceeds the maximal allowed length: {} > {}, ignore it",
n, maxMessageLength);
return;
}
SyslogMessage sm = new SyslogMessage();
sm.setFacility(syslog.getDefaultFacility());
if (notEmpty(localname)) {
sm.setHostname(localname);
}
sm.setSeverity(getSeverity(event.level()));
sm.setMsg(msg);
try {
syslog.sendMessage(sm);
} catch (IOException ex) {
LOG.error("could not send syslog message: {}", ex.getMessage());
LOG.debug("could not send syslog message", ex);
}
}
示例6: sendMessage
import com.cloudbees.syslog.SyslogMessage; //导入依赖的package包/类
/**
* Send the given {@link com.cloudbees.syslog.SyslogMessage}.
*
* @param message the message to send
* @throws IOException
*/
void sendMessage(@Nonnull SyslogMessage message) throws IOException;