This topic describes running StreamBase Server in background mode, describes how to configure the Apache Log4j logging mechanism enabled in that mode, and describes how to configure syslog on UNIX to receive messages from Log4j.
Run StreamBase Server in background mode by specifying the
–b option on the sbd command line, or by running StreamBase Server as a Windows service. (TIBCO does not recommend running
sbd -b at the StreamBase Command Prompt on Windows.)
In background mode, debug and console messages normally written to standard output using the embedded Logback mechanism are automatically redirected by default to an alternative embedded Apache Log4j logging mechanism. The reason for this automatic redirection is that Log4j provides a logging appender that can write to the Windows Event Log.
StreamBase logging in general is discussed in Using StreamBase Logging.
--working-directory options with the sbd command to specify a working directory for StreamBase Server when run in the background. The path specified with
-w is not automatically on the module search path, which must be specified as usual.
When specifying a startup working directory, you can express paths to resource files relative to the root of the working directory, or you can specify full, absolute paths.
When StreamBase Server starts in background mode without using the
--working-directory switch, its default working directory is the root of the file system,
/ on UNIX or
%windir%\System32 on Windows. When using the default working directory, you must express the path to any file system resources used by the
server with full, absolute paths. Use full paths on the sbd command line and in the server configuration file.
When using sbd -b on the command line, the launch of sbd fails if you specify a file system resource with a relative path. For example, the following commands work normally with
relative paths because
-b is not used:
UNIX: sbd -f ./sbd.sbconf ./myapp.sbapp Windows: sbd -f sbd.sbconf myapp.sbapp
However, if you add
-b to these commands, sbd fails to start, reporting the failure to the Event Log for Windows or to syslog for UNIX. To avoid this error, use full,
absolute paths, as shown in the following examples:
UNIX: sbd -b -f /home/sbuser/sbproj/sbd.sbconf /home/sbuser/sbproj/myapp.sbapp & Windows: sbd -b -f c:\sbproj\sbd.sbconf c:\sbproj\myapp.sbapp
Some of the file system resources that might be used by the server are described in the following table.
|File System Resource||Specifying with Server in Background Mode|
|server configuration file||Specify an absolute path to the configuration file with the
|primary application file to run||Specify an absolute path to the file, either as an argument on the sbd command line, or in a
|custom function plug-ins||Specify an absolute path to a file with the
|Java resources||Specify absolute paths to a Java home directory, and to any JAR files or other resources required by custom Java-based adapters
and operators. For example, in the
|data directory for disk-based Query Tables||Specify an absolute path to a directory, whether specified with
|Authentication password database||Specify an absolute path to the
On supported UNIX platforms, StreamBase Log4j logging is configured by default to write to the UNIX syslog mechanism using the standard UDP port for syslog remote access. Syslog must be configured to listen on its standard port, as described in Syslog Configuration on UNIX.
Run the server in background mode with a command like the following example:
sbd -b -f /
In the specified server configuration file, identify the absolute path to the primary application file to run, plus any container
information, TCP port to listen on, modules to load, and so on. You can set up a server to run automatically on host reboot
by using with a script managed by
cron, or using the
init.d mechanism installed by the StreamBase RPM installer (described in Installing StreamBase on Linux), or using another method you devise.
If you run
sbd –b at the StreamBase Command Prompt, the Server emits several benign console warning messages that complain about multiple SLF4J bindings. This is because the
StreamBase Command Prompt specifies a classpath that includes the default
sbclient.jar, in which the SLF4J front end is configured to log to the Logback back end. But the sbd command itself, when used with
-b, also internally references the SLF4J front end, this time configured to log to the Log4j back end.
Even though discouraged, it is still possible to run
sbd –b at the StreamBase Command Prompt without warning messages by unsetting the CLASSPATH environment variable and following the other steps in Advanced: Replacing Logback with Log4J. For an example, see the batch file
run-sbd-with-env.cmd in the
Configure background mode's Log4j logging mechanism by editing its configuration file. For both UNIX and Windows platforms,
the StreamBase Log4j configuration file is installed by default in
Your Log4j configuration can redirect the output to a file or can take advantage of any other valid Log4j mechanism. Refer to standard Log4j documentation for the various configuration options.
You can change the location or name of the Log4j configuration file by setting the
log4j.configuration system property for the JVM running the server. Do this in the server configuration file, using either the
<sysproperty> elements, like these examples:
<param name="jvm-args" value="-Xms128m -Xmx512m -Dlog4j.configuration="file:/c/sbproj/mylog4j.configuration" />
<sysproperty name="log4j.configuration" value="file:/home/sbuser/sbproj/mylog4j.configuration" />
Notice that the system property value is a Java URI, not a simple path name. See StreamBase Server Configuration File XML Reference for more on server configuration file elements.
Background mode's Log4j logging mechanism captures most, but not all debug and console messages from the running server. There are two sources of logging messages from StreamBase Server:
When running in background mode, the SLF4J back-end logging mechanism and the Log4j front end capture everything that runs in the server's Java virtual machine (JVM), including output from all running StreamBase applications, as well as much of the server infrastructure. The output from these components will conform to the configuration in the
StreamBase Server uses a small amount of native code for each platform to start and manage the JVM. Messages from this startup code includes information about server startup and shutdown, plus some miscellaneous output. These messages are not directed through SLF4J and Log4j, but are delivered directly to syslog for UNIX and to the Event Log for Windows.
On UNIX, you must configure the syslog daemon to listen for these startup messages, as described in the next section.
The syslog daemon receives messages in two ways, from programs making a system call that writes directly to syslog, or from programs that send messages to a known, standard UDP port. Messages sent from StreamBase Server's native startup code use the system call method, and do not require special configuration. However, messages sent from Log4j to syslog use the UDP port method, which must be enabled.
On Linux platforms, syslogd is typically installed but not configured to listen by default on its UDP port. Be aware that syslog logging is advisory only, and does not provide notification of dropped messages, which could happen when syslogd is not set up to listen for remote messages.
On Linux, the method to configure syslogd for remote access varies by Linux distribution. The following shows the steps for the Linux platforms supported by StreamBase.
For Red Hat Enterprise Linux version 6 and above, first, add (or uncomment) the following lines to
$ModLoad imudp.so $UDPServerRun 514
Then, restart the rsyslog service:
/sbin/service rsyslog restart
For Red Hat Enterprise Linux versions 5 and earlier, add
-rto SYSLOGD_OPTIONS in
/etc/sysconfig/syslog. Then stop and restart the syslog daemon by running the following command as root:
For SUSE Linux Enterprise Server, uncomment the UDP line in
/etc/syslog-ng/syslog-ng.conf.in. Then run the following commands as root:
/sbin/SuSEconfig --module syslog-nt /sbin/rcsyslog restart