Jump to: navigation, search

Difference between revisions of "EclipseLink/Examples/JPA/Logging"

(created logging example)
 
(Log Level Configuration)
Line 52: Line 52:
 
==Log Level Configuration==
 
==Log Level Configuration==
 
The log level configuration is included in the definition of the persistence unit in the persistence.xml file, as follows:
 
The log level configuration is included in the definition of the persistence unit in the persistence.xml file, as follows:
<property name="eclipselink.logging.level" value="FINE">  
+
<source lang="xml">
 
+
<property name="eclipselink.logging.level" value="FINE">  
 +
</source>
  
  
 
Every log output contains various optional details that you can configure using the following properties:
 
Every log output contains various optional details that you can configure using the following properties:
 
* '''Print Timestamp''' — you can set it in the persistence.xml file (see the following example) to determine when a log output was printed. The default value for this setting is true:
 
* '''Print Timestamp''' — you can set it in the persistence.xml file (see the following example) to determine when a log output was printed. The default value for this setting is true:
<property name="eclipselink.logging.timestamp" value="true">  
+
<source lang="xml">
 +
<property name="eclipselink.logging.timestamp" value="true">
 +
</source>
  
 
* '''Print Session''' — you can set it in the persistence.xml file (see the following example) to determine on which underlying session (if any) the message was sent. This setting is applicable to messages that require a database connection such as SQL, and the transaction information. The default value for this setting is true:
 
* '''Print Session''' — you can set it in the persistence.xml file (see the following example) to determine on which underlying session (if any) the message was sent. This setting is applicable to messages that require a database connection such as SQL, and the transaction information. The default value for this setting is true:
<property name="eclipselink.logging.session" value="true">  
+
<source lang="xml">
 +
<property name="eclipselink.logging.session" value="true">
 +
</source>
  
 
* '''Print Thread''' — you can set it in the persistence.xml file (see the following example) when you are running multithreaded applications to print the hashcode of the thread, which wrote the message. The default value for this setting is true:
 
* '''Print Thread''' — you can set it in the persistence.xml file (see the following example) when you are running multithreaded applications to print the hashcode of the thread, which wrote the message. The default value for this setting is true:
<property name="eclipselink.logging.thread" value="true">  
+
<source lang="xml">
 +
<property name="eclipselink.logging.thread" value="true">
 +
</source>
  
 
* '''Print Exceptions''' — you can set it in the persistence.xml file (see the following example) to enable logging of the exceptions's messages at the time when these exceptions are thrown. The default value for this setting is true:
 
* '''Print Exceptions''' — you can set it in the persistence.xml file (see the following example) to enable logging of the exceptions's messages at the time when these exceptions are thrown. The default value for this setting is true:
<property name="eclipselink.logging.exceptions" value="true">  
+
<source lang="xml">
 
+
<property name="eclipselink.logging.exceptions" value="true">
 +
</source>
  
 
==Summary==
 
==Summary==
 
You can configure logging at various levels to facilitate the debugging of your application. See the [[Using_EclipseLink_JPA_Extensions_%28ELUG%29#Using_EclipseLink_JPA_Extensions_for_Logging|Using EclipseLink JPA Extensions for Logging]] for the complete description of the available extensions.
 
You can configure logging at various levels to facilitate the debugging of your application. See the [[Using_EclipseLink_JPA_Extensions_%28ELUG%29#Using_EclipseLink_JPA_Extensions_for_Logging|Using EclipseLink JPA Extensions for Logging]] for the complete description of the available extensions.

Revision as of 15:07, 23 June 2008

How To Configure Logging

This document describes how to configuring logging with EclipseLink JPA. See Logging in the EclipseLink User's Guide for complete information.


Introduction

With EclipseLink JPA you can turn on logging to do the following:

  • monitor configuration details
  • facilitate debugging
  • view the SQL that is being sent to the database

The logging utility is based on the java.util.logging. This utility provides you with nine levels of logging control over the amount and detail of the log output. Note that, as logging is not part of the JPA specification, the information the log output provides is EclipseLink JPA-specific.


Log Levels

Level Description
OFF This setting disables the generation of the log output. You may want to set logging to OFF during production to avoid the overhead of logging.
SEVERE This level enables reporting of failure cases only. Usually, if the failure occurs, the application stops.
WARNING This level enables logging of issues that have a potential to cause problems. For example, a setting that is picked by the application and not by the user.
INFO This level enables the standard output. The contents of this output is very limited.
CONFIG This level enables logging of such configuration details as your database login information and some metadata information. You may want to use the CONFIG log level at deployment time.
FINE This level enables logging of the first level of the debugging information and SQL. You may want to use this log level during debugging and testing, but not at production.
FINER This level enables logging of more debugging information than the FINE setting. For example, the transaction information is logged at this level. You may want to use this log level during debugging and testing, but not at production.
FINEST This level enables logging of more debugging information than the FINER setting, such as a very detailed information about certain features (for example, sequencing). You may want to use this log level during debugging and testing, but not at production.


The logging information accumulates at every sequential log level: each log output includes the information from the output of the previous log level. For example, if you set the log level to INFO, your output will include log messages from INFO, WARNING, and SEVERE levels.


Log Level Configuration

The log level configuration is included in the definition of the persistence unit in the persistence.xml file, as follows:

<property name="eclipselink.logging.level" value="FINE">


Every log output contains various optional details that you can configure using the following properties:

  • Print Timestamp — you can set it in the persistence.xml file (see the following example) to determine when a log output was printed. The default value for this setting is true:
<property name="eclipselink.logging.timestamp" value="true">
  • Print Session — you can set it in the persistence.xml file (see the following example) to determine on which underlying session (if any) the message was sent. This setting is applicable to messages that require a database connection such as SQL, and the transaction information. The default value for this setting is true:
<property name="eclipselink.logging.session" value="true">
  • Print Thread — you can set it in the persistence.xml file (see the following example) when you are running multithreaded applications to print the hashcode of the thread, which wrote the message. The default value for this setting is true:
<property name="eclipselink.logging.thread" value="true">
  • Print Exceptions — you can set it in the persistence.xml file (see the following example) to enable logging of the exceptions's messages at the time when these exceptions are thrown. The default value for this setting is true:
<property name="eclipselink.logging.exceptions" value="true">

Summary

You can configure logging at various levels to facilitate the debugging of your application. See the Using EclipseLink JPA Extensions for Logging for the complete description of the available extensions.