-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deleted a LogHandler warning message (#75)
- Loading branch information
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
...-impl/glassfish/src/main/java/com/sun/enterprise/server/logging/ServerLogFileService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |