All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.glassfish.grizzly.http.server.accesslog.FileAppender Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0, which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * This Source Code may also be made available under the following Secondary
 * Licenses when the conditions for such availability set forth in the
 * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
 * version 2 with the GNU Classpath Exception, which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 */

package org.glassfish.grizzly.http.server.accesslog;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.logging.Logger;

import org.glassfish.grizzly.Grizzly;
import org.glassfish.grizzly.http.server.HttpServer;

/**
 * An {@link AccessLogAppender appender} writing log entries to {@link File}s.
 *
 * @author Pier Fumagalli
 * @author USRZ.com
 */
public class FileAppender extends StreamAppender {

    private static final Logger LOGGER = Grizzly.logger(HttpServer.class);

    /**
     * Create a new {@link FileAppender} appending to (and not overwriting) the specified {@link File}.
     *
     * @throws IOException If an I/O error occurred opening the file.
     */
    public FileAppender(File file) throws IOException {
        this(file, true);
    }

    /**
     * Create a new {@link FileAppender} writing to the specified {@link File}.
     *
     * @param append If true the file will be appended to, otherwise it will be completely
     * overwritten.
     * @throws IOException If an I/O error occurred opening the file.
     */
    public FileAppender(File file, boolean append) throws IOException {
        super(new FileOutputStream(file, append));
        LOGGER.info("Access log file \"" + file.getAbsolutePath() + "\" opened");
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy