Personal tools
gvSIG Desktop
gvSIG Desktop

Cached time 11/21/13 17:02:30 Clear cache and reload

 
The logging API to use in gvSIG 2.0 is the SLF4J library. If the project being migrated is using another logging API, such as Log4J or java.util.logging, then it needs to be replaced with the SLF4J logging API. You can find more information on SLF4J in the `section on logging in the development guide`_

In general, the steps needed to migrate from Log4J to SLF4J are:

1.- Replace the Log4J import classes with those of SLF4J:

.. code-block:: java

      import org.slf4j.Logger;
      import org.slf4j.LoggerFactory;
      // substituting the import of Log4j ...
      // import org.apache.log4j.Logger;

2.- Change the *Logger* definition:


.. code-block:: java

      private static final Logger LOG = Logger.getLogger(MyClasser.class);
      ...

To:

.. code-block:: java

      private static final Logger LOG = LoggerFactory.getLogger(MyClass.class);
      ...

3.- Use message parameters where appropriate. For example:

.. code-block:: java

      LOG.debug("Point values: X = " + point.getX() + ", Y = " + point.getY());
      ...

To:

.. code-block:: java

      LOG.debug("Point values: X = {}, Y = {}", point.getX(), point.getY());
      ...

.. _section on logging in the development guide: /web/docdev/docs/v2_0/gvsig-devel-guide/coding-development-guidelines/logging

View source document


Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: