Solaris_LogServiceProperties クラスのインスタンスを作成し、そのプロパティ値を設定すれば、アプリケーションやプロバイダでロギングをどのように扱うかを制御できます。次の例は、ロギングプロパティの設定方法を示したものです。プロパティは、/usr/sadm/bin/wbem/wbemservices.properties ファイルに格納されます。
public class SetProps { public static void main(String args[]) throws CIMException { if ( args.length != 3) { System.out.println("Usage: SetProps host username password"); System.exit(1); } CIMClient cc = null; try { CIMNameSpace cns = new CIMNameSpace(args[0]); cc = new CIMClient(cns, args[1], args[2]); CIMObjectPath logpropcop = new CIMObjectPath("Solaris_Log ServiceProperties"); Enumeration e = cc.enumInstances(logpropcop, true); for (; e.hasMoreElements(); ) { CIMObjectPath op = (CIMObjectPath)e.nextElement(); CIMInstance ci = cc.getInstance(op); ci.setProperty("Directory", new CIMValue("/tmp/bar1/")); ci.setProperty("FileSize", new CIMValue("10")); ci.setProperty("NumFiles", new CIMValue("2")); ci.setProperty("SyslogSwitch", new CIMValue("off")); cc.setInstance(logpropcop,ci); } } catch (Exception e) { System.out.println("Exception: "+e); e.printStackTrace(); } // セッションを閉じる。 if(cc != null) { cc.close(); } } |