-
Notifications
You must be signed in to change notification settings - Fork 244
Dispatchers and receivers
We use 'receivers' term for back-end byte receivers, like log files, network channels, etc.
We use 'dispatchers' term for intermediate elements which send messages to multiple underlying receivers/dispatchers.
This is a simple example that visualizes these two concepts. Here dispatchers are green and receivers are white. Note the 'filter' dispatcher: it sends only 'critical' messages to its underlying elements.
The main goal of creating such configurations is to create different groups with common format options or allowed log levels. For example, let's create an example config for the diagram above:
<sealog>
<outputs>
<splitter formatid="common">
<console/>
<file path="file.log"/>
<network address="192.168.0.2" port="8123"/>
</splitter>
<filter levels="critical">
<file path="critical.log" formatid="critical"/>
<smtp credentialsfile="smtp.cred" address="��admin@cin.io" formatid="criticalemail"/>
</filter>
</outputs>
<formats>
<format id="common" format="[%LVL] %Msg"/>
<format id="critical" format="%Time %Date %RelFile %Func %Msg"/>
<format id="criticalemail" format="Critical error on our server!\n %Time %Date %RelFile %Func %Msg \nSent by Sealog"/>
</formats>
</sealog>
So, here we use a 'splitter' element to group three receivers by format ('common') and other two receivers are grouped by allowed log level using a 'filter'. Note that top element 'outputs' is a splitter itself, so we could simplify the config:
<sealog>
<outputs formatid="common">
<console/>
<file path="file.log"/>
<network address="192.168.0.2" port="8123"/>
<filter levels="critical">
<file path="critical.log" formatid="critical"/>
<smtp credentialsfile="smtp.cred" address="��admin@cin.io" formatid="criticalemail"/>
</filter>
</outputs>
<formats>
<format id="common" format="[%LVL] %Msg"/>
<format id="critical" format="%Time %Date %RelFile %Func %Msg"/>
<format id="criticalemail" format="Critical error on our server!\n %Time %Date %RelFile %Func %Msg \nSent by Sealog"/>
</formats>
</sealog>
This config would practically do the same as the config above, but it is more efficient. Dispatcher diagram for this config looks like: