You can enable Connect 8.x application server to output log files to SYSLOG endpoints.

Connect 8 adds many logging configuration options using the Apache log4j.xml utility.

For more information on the log4j config format and usage, see the following sites:

  • http://logging.apache.org/log4j/1.2/manual.html  
  • http://wiki.apache.org/logging-log4j/Log4jXmlFormat

To use SYSLOG with Connect, you use the C:\Breeze\8.x.x\appserv\conf\log4j.xml file/

To send logs to Syslog locate the entry, do the following: 

<appender class="org.apache.log4j.net.SyslogAppender" name="SYSLOG">
<param name="Threshold" value="INFO"/>    
<param name="Facility" value="USER"/>    
<param name="FacilityPrinting" value="true"/>  
<param name="syslogHost" value="${syslog.host}"/>    
<layout class="org.apache.log4j.PatternLayout">      
<param  name="ConversionPattern" value="${syslog.localhost}%d{dd-MM-yyyy HH:mm:ss}%.8t %-5p(%C:%M:%L) - %m%n"/>        
</layout>        
</appender>

Replace the ${syslog.host} with IP or host name of your Syslog host. The syslogHost parameter is the name of the syslog host where log output goes. You can specify a nondefault port by appending a colon and port number to a host name, an IPv4 address, or an IPv6 address enclosed in brackets.

If you have multiple syslog hosts that you want to send logs to, add an extra <appender></appender> tag for each one.

 For example, you could set different log level for each Syslog server:

<appender name="SYSLOG" class="org.apache.log4j.net.SyslogAppender"> 

 <param name="Threshold" value="WARN"/> 
  <param name="Facility" value="USER"/> 
  <param name="FacilityPrinting" value="true"/>                    
  <param name="syslogHost" value="10.1.1.1"/> 
  <layout class="org.apache.log4j.PatternLayout"> 
  <param name="ConversionPattern" value="${syslog.localhost} %d{dd-MM-yyyy HH:mm:ss}  %.8t %-5p(%C:%M:%L) - %m%n"/> 
  </layout> 

</appender> 

<appender name="SYSLOG" class="org.apache.log4j.net.SyslogAppender">
 
  <param name="Threshold" value="INFO"/> 
  <param name="Facility" value="USER"/> 
  <param name="FacilityPrinting" value="true"/>    
  <param name="syslogHost" value="10.2.2.2"/> 
  <layout class="org.apache.log4j.PatternLayout"> 
  <param name="ConversionPattern" value="${syslog.localhost} %d{dd-MM-yyyy HH:mm:ss}  %.8t %-5p(%C:%M:%L) - %m%n"/> 
 </layout> 

 </appender>

 

 You can customize which messages get sent to syslog.

The log4j structure is used to define the following:

  •  Independent appenders, which write to file/syslog/Windows Event Log, and so on.
  •  Define loggers, which the app can write to specifically for certain cases or automatically by class.

Each logger can reference one or many appenders to write to. So if you wanted to write the error log to syslog, that’s the CUST_ERROR logger you would change this block of code:

Change the following:

<logger name="CUST_ERROR"> 

     <appender-ref ref="CUSTERRORLOG"/>

   </logger>

 to

<logger name="CUST_ERROR"> 

     <appender-ref ref="SYSLOG"/> 

   </logger>

 

You can also adjust the level of messages that each appender writes through with the Threshold attribute. By default, the SYSLOG appender uses INFO:

<appender name="SYSLOG" class="org.apache.log4j.net.SyslogAppender">                  

 <param name="Threshold" value="INFO"/> 
 <param name="Facility" value="USER"/> 
 <param name="FacilityPrinting" value="true"/>          
 <param name="syslogHost" value="${syslog.host}"/> 
 <layout class="org.apache.log4j.PatternLayout"> 
     <param name="ConversionPattern" value="${syslog.localhost} %d{dd-MM-yyyy HH:mm:ss}  %.8t %-5p(%C:%M:%L) - %m%n"/>
 </layout> 

</appender>

For example, you could define a SYSLOG appender for the debug log with a threshold of ERROR. Then, add a reference to it in the loggers that reference DEBUGLOG. Messages written to the debug log at that severe level also get written to syslog.

Also, there are different appender classes that you could use that would roll over the log files by size instead of date.

There’s much flexibility, and it's not necessary to use the defaults. You can rework it to suit your needs and environment.

 

 

 

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy