Java Log to File log(Level level, String methodName, Object message)

Here you can find the source of log(Level level, String methodName, Object message)

Description

Writes a log entry.

License

CDDL license

Declaration

protected static void log(Level level, String methodName, Object message) 

Method Source Code

//package com.java2s;
/* The contents of this file are subject to the terms
 (updated)// w  w  w  . j av  a2s  .com
 * of the Common Development and Distribution License
 * (the License). You may not use this file except in
 * compliance with the License.
 *
 * You can obtain a copy of the License at
 * https://opensso.dev.java.net/public/CDDLv1.0.html or
 * opensso/legal/CDDLv1.0.txt
 * See the License for the specific language governing
 * permission and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL
 * Header Notice in each file and include the License file
 * at opensso/legal/CDDLv1.0.txt.
 * If applicable, add the following below the CDDL Header,
 * with the fields enclosed by brackets [] replaced by
 * your own identifying information:
 * "Portions Copyrighted [year] [name of copyright owner]"
 *
 * $Id: TestCommon.java,v 1.78 2009-08-05 21:42:36 rmisra Exp $
 *
 * Copyright 2007 Sun Microsystems Inc. All Rights Reserved
 */

import java.text.MessageFormat;

import java.util.logging.Level;
import java.util.logging.Logger;

public class Main {
    static private Logger logger;
    static private String logEntryTemplate;

    /**
     * Writes a log entry.
     */
    protected static void log(Level level, String methodName, Object message) {
        Object[] args = { methodName, message };
        logger.log(level, MessageFormat.format(logEntryTemplate, args));
    }

    /**
     * Writes a log entry.
     */
    protected void log(Level level, String methodName, String message, Object[] params) {
        Object[] args = { methodName, message };
        logger.log(level, MessageFormat.format(logEntryTemplate, args), params);
    }
}

Related

  1. log(String message)
  2. log(String message)
  3. log(String message)
  4. log(String message, Exception e)