Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Deleted a LogHandler warning message #75

Merged
merged 1 commit into from
Jun 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright (c) 2023 Fujitsu Limited.
* Copyright (c) 2022 Contributors to the Eclipse Foundation
*
* 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 com.sun.enterprise.server.logging;

import jakarta.inject.Singleton;

import java.io.File;
import java.lang.System.Logger.Level;

import org.glassfish.main.jul.JULHelperFactory;
import org.glassfish.main.jul.JULHelperFactory.JULHelper;
import org.glassfish.main.jul.handler.GlassFishLogHandler;
import org.jvnet.hk2.annotations.ContractsProvided;
import org.jvnet.hk2.annotations.Service;

/**
* This service is used to rotate the server.log file (if it is configured).
*
* @author Jerome Dochez
* @author Carla Mott
* @author David Matejcek
*/
@Service
@Singleton
@ContractsProvided(ServerLogFileManager.class)
public class ServerLogFileService implements ServerLogFileManager {

private final JULHelper julHelper = JULHelperFactory.getHelper();


@Override
public File getCurrentLogFile() {
final GlassFishLogHandler logHandler = julHelper.findGlassFishLogHandler();
if (logHandler == null) {
return null;
}
return logHandler.getConfiguration().getLogFile();
}


/**
* Renames the server.log file and starts logging to a new file.
*/
@Override
public void roll() {
final GlassFishLogHandler logHandler = julHelper.findGlassFishLogHandler();
if (logHandler == null) {
throw new IllegalStateException("The GlassFishLogHandler was not found, rolling the output file failed.");
}
logHandler.roll();
}
}