Search in sources :

Example 51 with FileHandler

use of java.util.logging.FileHandler in project Board-Instrumentation-Framework by intel.

the class MarvinLogger method setup.

public static void setup(String fileName) throws IOException {
    try {
        Logger logger = Logger.getLogger(MarvinLogger.class.getName());
        // logger.setLevel(Level.ALL);
        // 10 Mb maximum, then cut off
        int limit = 1024000 * 10;
        _marvinLogFile = new FileHandler(fileName, limit, 1);
        _marvinLogFormatObj = new MarvinHtmlLoggerFormatter();
        _marvinLogFile.setFormatter(_marvinLogFormatObj);
        logger.addHandler(_marvinLogFile);
        /*
	     * ConsoleHandler consoleHandler = new ConsoleHandler();
	     * consoleHandler.setFormatter(new SimpleFormatter());
	     * logger.addHandler(consoleHandler);
	     */
        setDebugLevel(Level.WARNING);
    } catch (Exception ex) {
        System.out.println(ex.toString());
    }
}
Also used : Logger(java.util.logging.Logger) IOException(java.io.IOException) FileHandler(java.util.logging.FileHandler)

Example 52 with FileHandler

use of java.util.logging.FileHandler in project litiengine by gurkenlabs.

the class GameLog method init.

void init() {
    LogManager.getLogManager().reset();
    if (new File(LOGGING_CONFIG_FILE).exists()) {
        System.setProperty("java.util.logging.config.file", LOGGING_CONFIG_FILE);
        try {
            LogManager.getLogManager().readConfiguration();
        } catch (final Exception e) {
            log.log(Level.SEVERE, e.getMessage(), e);
        }
    } else {
        try {
            final ConsoleHandler consoleHandler = new ConsoleHandler();
            consoleHandler.setLevel(Level.ALL);
            consoleHandler.setFormatter(new SimpleFormatter());
            final FileHandler fileHandler = new FileHandler("game.log", 50000, 1, true);
            fileHandler.setLevel(Level.WARNING);
            fileHandler.setFormatter(new SimpleFormatter());
            final Logger logger = Logger.getLogger("");
            logger.addHandler(consoleHandler);
            logger.addHandler(fileHandler);
        } catch (final Exception e) {
            log.log(Level.SEVERE, e.getMessage(), e);
        }
    }
}
Also used : SimpleFormatter(java.util.logging.SimpleFormatter) Logger(java.util.logging.Logger) File(java.io.File) ConsoleHandler(java.util.logging.ConsoleHandler) FileHandler(java.util.logging.FileHandler)

Example 53 with FileHandler

use of java.util.logging.FileHandler in project zemberek-nlp by ahmetaa.

the class Log method removeFileHandler.

public static void removeFileHandler(File file) {
    if (fileHandlers.containsKey(file)) {
        FileHandler handler = fileHandlers.remove(file);
        logger.removeHandler(handler);
    }
}
Also used : FileHandler(java.util.logging.FileHandler)

Example 54 with FileHandler

use of java.util.logging.FileHandler in project zemberek-nlp by ahmetaa.

the class Log method addFileHandler.

public static void addFileHandler(Path path) throws IOException {
    if (fileHandlers.containsKey(path.toFile())) {
        Log.info("Log File %s already exist. Appending.", path.toFile());
        return;
    }
    final FileHandler handler = new FileHandler(path.toFile().getAbsolutePath(), true);
    handler.setFormatter(formatter);
    handler.setLevel(currentLevel);
    logger.addHandler(handler);
    fileHandlers.put(path.toFile(), handler);
}
Also used : FileHandler(java.util.logging.FileHandler)

Example 55 with FileHandler

use of java.util.logging.FileHandler in project jain-sip.ha by RestComm.

the class B2BUAEarlyDialogRecoveryOn1xxTest method testEarlyDialogFailoverOn1xx.

/**
 * UA1			B2BUA (Engine1)			B2BUA (Engine2)			UA2
 * INVITE (CSeq 1)
 * --------------------->
 *
 * 				INVITE (CSeq 1)
 * 				------------------------------------------------->
 *
 * 											INVITE (CSeq 1)
 * 								             <---------------------
 * 					INVITE (CSeq 1)
 * <------------------------------------------
 *
 *  BYE (CSeq 2)
 *  ------------------------------------------->
 *  												BYE (CSeq 2)
 *  											-------------------->
 */
public void testEarlyDialogFailoverOn1xx() throws Exception {
    balancer = new BalancerRunner();
    Handler fh = new FileHandler("logs/sipbalancer_util.log");
    fh.setFormatter(new SimpleFormatter());
    Logger.getLogger("org.mobicents").addHandler(fh);
    Logger.getLogger("org.mobicents").setLevel(Level.FINEST);
    Properties properties = new Properties();
    properties.setProperty("javax.sip.STACK_NAME", "SipBalancerForwarder");
    properties.setProperty("javax.sip.AUTOMATIC_DIALOG_SUPPORT", "off");
    // You need 16 for logging traces. 32 for debug + traces.
    // Your code will limp at 32 but it is best for debugging.
    properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "32");
    properties.setProperty("gov.nist.javax.sip.DEBUG_LOG", "logs/sipbalancerforwarderdebug.txt");
    properties.setProperty("gov.nist.javax.sip.SERVER_LOG", "logs/sipbalancerforwarder.xml");
    properties.setProperty("gov.nist.javax.sip.THREAD_POOL_SIZE", "8");
    properties.setProperty("gov.nist.javax.sip.REENTRANT_LISTENER", "true");
    properties.setProperty("gov.nist.javax.sip.CANCEL_CLIENT_TRANSACTION_CHECKED", "false");
    // properties.setProperty("algorithmClass", InviteTransactionFailover.class.getName());
    properties.setProperty("host", IP_ADDRESS);
    properties.setProperty("internalPort", "5065");
    properties.setProperty("externalPort", "5060");
    balancer.start(properties);
    shootist = new Shootist("shootist_reinvite", true);
    shootme = new Shootme("shootme_reinvite", 5070, true);
    b2buaNode1 = new SimpleB2BUA("b2buaNode1_reinvite", 5080, IP_ADDRESS, ListeningPoint.UDP, ReplicationStrategy.EarlyDialog, true);
    Thread.sleep(5000);
    b2buaNode2 = new SimpleB2BUA("b2buaNode2_reinvite", 5081, IP_ADDRESS, ListeningPoint.UDP, ReplicationStrategy.EarlyDialog, true);
    b2buaNode1.getB2buaHandler().setSendAckOn2xx(true);
    b2buaNode2.getB2buaHandler().setSendAckOn2xx(true);
    Thread.sleep(5000);
    b2buaNode1.pingBalancer();
    Thread.sleep(1000);
    b2buaNode2.pingBalancer();
    Thread.sleep(1000);
    shootist.setFailoverOn1xx(true);
    shootme.init();
    shootist.init("ReInvite");
    Thread.sleep(100000);
    shootme.checkState(false);
    shootist.checkState(false);
    // make sure dialogs are removed on both nodes
    // non regression for Issue 1418
    // http://code.google.com/p/restcomm/issues/detail?id=1418
    assertTrue(b2buaNode1.checkDialogsRemoved());
    assertTrue(b2buaNode2.checkDialogsRemoved());
    assertTrue(b2buaNode1.checkTransactionsRemoved());
    assertTrue(b2buaNode2.checkTransactionsRemoved());
    balancer.stop();
    b2buaNode1.stop();
    b2buaNode2.stop();
    shootist.stop();
    shootme.stop();
    Thread.sleep(5000);
}
Also used : BalancerRunner(org.mobicents.tools.sip.balancer.BalancerRunner) SimpleFormatter(java.util.logging.SimpleFormatter) FileHandler(java.util.logging.FileHandler) Handler(java.util.logging.Handler) Properties(java.util.Properties) FileHandler(java.util.logging.FileHandler)

Aggregations

FileHandler (java.util.logging.FileHandler)139 SimpleFormatter (java.util.logging.SimpleFormatter)59 IOException (java.io.IOException)49 File (java.io.File)48 Logger (java.util.logging.Logger)36 Handler (java.util.logging.Handler)34 ConsoleHandler (java.util.logging.ConsoleHandler)15 Properties (java.util.Properties)14 BalancerRunner (org.mobicents.tools.sip.balancer.BalancerRunner)13 Formatter (java.util.logging.Formatter)12 Config (edu.neu.ccs.pyramid.configuration.Config)11 Date (java.util.Date)11 LogRecord (java.util.logging.LogRecord)10 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 Level (java.util.logging.Level)4 Pair (edu.neu.ccs.pyramid.util.Pair)3 FileInputStream (java.io.FileInputStream)3 FileNotFoundException (java.io.FileNotFoundException)3 LogFormat (de.Keyle.MyPet.api.util.LogFormat)2 CTFT (edu.neu.ccs.pyramid.calibration.CTFT)2