1 23 package com.sun.enterprise.server.logging; 24 25 import java.util.logging.Handler ; 26 import java.util.logging.LogRecord ; 27 28 import com.sun.enterprise.util.SystemPropertyConstants; 29 30 31 public class SystemLogHandler extends Handler { 32 public native void logMessage(String fileName, String level, 33 String message); 34 35 private static final String SYSLOG_FILE_PREFIX = "SJSAS81"; 36 37 private String syslogFileName = SYSLOG_FILE_PREFIX; 40 41 public SystemLogHandler( ) { 42 try { 43 System.loadLibrary( "utilforsyslog" ); 44 String serverName = System.getProperty( 51 SystemPropertyConstants.SERVER_NAME ); 52 String clusterId = System.getProperty( 53 SystemPropertyConstants.CLUSTER_NAME ); 54 if( clusterId != null ) { 55 syslogFileName = syslogFileName + "_" + clusterId; 56 } 57 if( serverName != null ) { 58 syslogFileName = syslogFileName + "_" + serverName; 59 } 60 syslogFileName = syslogFileName + ".log"; 61 } catch( Exception e ) { 62 System.err.println( "Exception in loading Syslog Library..." + e ); 63 e.printStackTrace( ); 64 } 65 } 66 67 public synchronized void publish( LogRecord record ) { 68 logMessage( syslogFileName, record.getLevel().toString(), 69 getFormatter().format( record ) ); 70 } 71 72 public void close( ) { } 73 74 public void flush( ) { } 75 } 76 77 78 79 | Popular Tags |