Java Code Examples for java.util.logging.Logger.exiting()

The following are Jave code examples for showing how to use exiting() of the java.util.logging.Logger class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: store-app-ee   File: LoggingInterceptor.java   View Source Code Vote up 6 votes
@AroundInvoke
public Object interceptMethodInvocation(InvocationContext invocationContext) throws Exception {

    final String methodName = invocationContext.getMethod().getName();
    final String className = invocationContext.getTarget().getClass().getName();

    Logger logger = Logger.getLogger(className);

    final long timeBeforeMethodInvocation;
    final long timeAfterMethodInvocation;
    final long millis;
    logger.entering(className, methodName);
    timeBeforeMethodInvocation = System.currentTimeMillis();

    try {
        return invocationContext.proceed();
    } finally {
        timeAfterMethodInvocation = System.currentTimeMillis();
        millis = timeAfterMethodInvocation - timeBeforeMethodInvocation;
        logger.fine("Method took -> " + millis + " millis to be executed!");
        logger.exiting(className, methodName);
    }
}
 
Example 2
Project: Java-9-Concurrency-Cookbook-Second-Edition   File: Task.java   View Source Code Vote up 5 votes
/**
 * Main method of the task
 */
@Override
public void run() {
	/*
	 * Get the Logger
	 */
	Logger logger=MyLoggerFactory.getLogger(this.getClass().getName());
	
	/*
	 * Write a message indicating the start of the task
	 */
	logger.entering(Thread.currentThread().getName(), "run()");
	
	/*
	 * Sleep the task for two seconds
	 */
	try {
		TimeUnit.SECONDS.sleep(2);
	} catch (InterruptedException e) {
		e.printStackTrace();
	}
	
	/*
	 * Write a message indicating the end of the task
	 */
	logger.exiting(Thread.currentThread().getName(), "run()");
}
 
Example 3
Project: Java-SE-9-Road-to-Concurrent-and-High-Performance-Programming   File: Task.java   View Source Code Vote up 5 votes
/**
 * Main method of the task
 */
@Override
public void run() {
	/*
	 * Get the Logger
	 */
	Logger logger=MyLoggerFactory.getLogger(this.getClass().getName());
	
	/*
	 * Write a message indicating the start of the task
	 */
	logger.entering(Thread.currentThread().getName(), "run()");
	
	/*
	 * Sleep the task for two seconds
	 */
	try {
		TimeUnit.SECONDS.sleep(2);
	} catch (InterruptedException e) {
		e.printStackTrace();
	}
	
	/*
	 * Write a message indicating the end of the task
	 */
	logger.exiting(Thread.currentThread().getName(), "run()");
}
 
Example 4
Project: Java-9-Concurrency-Cookbook-Second-Edition   File: Main.java   View Source Code Vote up 4 votes
/**
 * @param args
 */
public static void main(String[] args) {
	
	/*
	 * Get the Logger object
	 */
	Logger logger=MyLoggerFactory.getLogger(Main.class.getName());
	
	/*
	 * Write a message indicating the start of the execution
	 */
	logger.entering(Main.class.getName(), "main()",args);
	
	/*
	 * Create and launch five Task objects
	 */
	Thread threads[]=new Thread[5];
	for (int i=0; i<threads.length; i++) {
		logger.log(Level.INFO,"Launching thread: "+i);
		Task task=new Task();
		threads[i]=new Thread(task);
		logger.log(Level.INFO,"Thread created: "+threads[i].getName());
		threads[i].start();
	}
	
	/*
	 * Write a log message indicating that the threads have been created
	 */
	logger.log(Level.INFO,"Ten Threads created. Waiting for its finalization");
	
	/*
	 * Wait for the finalization of the threads
	 */
	for (int i=0; i<threads.length; i++) {
		try {
			threads[i].join();
			logger.log(Level.INFO,"Thread has finished its execution",threads[i]);
		} catch (InterruptedException e) {
			logger.log(Level.SEVERE, "Exception", e);
		}
	}
	
	/*
	 * Write a log message indicating the end of the program
	 */
	logger.exiting(Main.class.getName(), "main()");
}
 
Example 5
Project: Java-SE-9-Road-to-Concurrent-and-High-Performance-Programming   File: Main.java   View Source Code Vote up 4 votes
/**
 * @param args
 */
public static void main(String[] args) {
	
	/*
	 * Get the Logger object
	 */
	Logger logger=MyLoggerFactory.getLogger(Main.class.getName());
	
	/*
	 * Write a message indicating the start of the execution
	 */
	logger.entering(Main.class.getName(), "main()",args);
	
	/*
	 * Create and launch five Task objects
	 */
	Thread threads[]=new Thread[5];
	for (int i=0; i<threads.length; i++) {
		logger.log(Level.INFO,"Launching thread: "+i);
		Task task=new Task();
		threads[i]=new Thread(task);
		logger.log(Level.INFO,"Thread created: "+threads[i].getName());
		threads[i].start();
	}
	
	/*
	 * Write a log message indicating that the threads have been created
	 */
	logger.log(Level.INFO,"Ten Threads created. Waiting for its finalization");
	
	/*
	 * Wait for the finalization of the threads
	 */
	for (int i=0; i<threads.length; i++) {
		try {
			threads[i].join();
			logger.log(Level.INFO,"Thread has finished its execution",threads[i]);
		} catch (InterruptedException e) {
			logger.log(Level.SEVERE, "Exception", e);
		}
	}
	
	/*
	 * Write a log message indicating the end of the program
	 */
	logger.exiting(Main.class.getName(), "main()");
}