Enabling Logging Dynamically in jConnect

Dynamically enable logging by using LogHandler API programmatically in your application.

  1. Enable or disable logging by programmatically using LogHandler API. Enter the following code to enable console-level logging on SybConnection and SybStatement classes:
    LogManager logManager = LogManager.getLogManager();
    	Handler handler = new ConsoleHandler();
    	handler.setLevel(Level.ALL);
    	Logger connLOG = Logger.getLogger(SybConnection.class.getName());
    	connLOG.addHandler(handler);
    	connLOG.setLevel(Level.FINE);
    	logManager.addLogger(connLOG);
    	Logger stmtLOG = Logger.getLogger(SybStatement.class.getName());
    	stmtLOG.addHandler(handler);
    	stmtLOG.setLevel(Level.FINE);
    	logManager.addLogger(stmtLOG);
  2. Run the application.
  3. You can tune the logging setting dynamically using the LogHandler as given in Step 1. Some of the suggested ways to achieve this:
    • Expose an interface where you can change a property that internally manages logging levels.
    • Run a surrogate thread that tunes the logging as required in your application.