org.eclipse.persistence.platform.server.ServerLog Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eclipselink Show documentation
Show all versions of eclipselink Show documentation
EclipseLink build based upon Git transaction 346465e
/*******************************************************************************
* Copyright (c) 1998, 2013 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 v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Oracle - initial API and implementation from Oracle TopLink
******************************************************************************/
package org.eclipse.persistence.platform.server;
import java.io.*;
import org.eclipse.persistence.internal.helper.*;
import org.eclipse.persistence.exceptions.*;
import org.eclipse.persistence.logging.*;
/**
*
* Basic logging class that provides framework for integration with the application
* server log. This class is used when messages need to be logged through an application
* server, e.g. OC4J.
*
* @see SessionLog
* @see AbstractSessionLog
* @see SessionLogEntry
* @see Session
*
*/
public class ServerLog extends AbstractSessionLog {
/**
* PUBLIC:
*
* Create and return a new ServerLog.
*
*/
public ServerLog() {
super();
}
/**
* PUBLIC:
*
* Log a SessionLogEntry
*
*
* @param entry SessionLogEntry that holds all the information for a TopLink logging event
*
*/
public void log(SessionLogEntry entry) {
if (!shouldLog(entry.getLevel())) {
return;
}
String message = getSupplementDetailString(entry);
if (entry.hasException()) {
if (entry.getLevel() == SEVERE) {
message += Helper.printStackTraceToString(entry.getException());
} else if (entry.getLevel() <= WARNING) {
if (shouldLogExceptionStackTrace()) {
message += Helper.printStackTraceToString(entry.getException());
} else {
message += entry.getException();
}
}
} else {
message += formatMessage(entry);
}
basicLog(entry.getLevel(), entry.getNameSpace(), message);
}
/**
*
* Log message to a writer by default. It needs to be overridden by the subclasses.
*
*
* @param level the log request level
*
* @param message the formatted string message
*
*/
protected void basicLog(int level, String category, String message) {
try {
printPrefixString(level, null);
getWriter().write(message);
getWriter().write(Helper.cr());
getWriter().flush();
} catch (IOException exception) {
throw ValidationException.logIOError(exception);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy